mercurial/compat.h
author Martin von Zweigbergk <martinvonz@google.com>
Fri, 15 Jun 2018 22:37:01 -0700
changeset 38345 bec1212eceaa
parent 33926 f4433f2713d0
child 39610 11ed2eadf937
permissions -rw-r--r--
progress: create helper class for incrementing progress When using ui.progress(), there's a clear pattern that is followed: * Pass the same topic and unit * Usually pass the same total * Call with pos=None to close the progress bar * Often keep track of the current position and increment it This patch creates a simple helper class for this. I'll probably make it implement the context manager protocol later (calling update(None) on __exit__). Progress is used in low-level modules like changegroup, so I also exposed it via a method on the ui object. Perhaps the class itself should also live in ui.py? This patch also makes merge.oy use it to show that it works. Differential Revision: https://phab.mercurial-scm.org/D3765
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29444
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     1
#ifndef _HG_COMPAT_H_
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     2
#define _HG_COMPAT_H_
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     3
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     4
#ifdef _WIN32
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     5
#ifdef _MSC_VER
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     6
/* msvc 6.0 has problems */
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     7
#define inline __inline
29521
83147ff53112 compat: provide a declaration of ssize_t, for MS windows
Maciej Fijalkowski <fijall@gmail.com>
parents: 29444
diff changeset
     8
#if defined(_WIN64)
83147ff53112 compat: provide a declaration of ssize_t, for MS windows
Maciej Fijalkowski <fijall@gmail.com>
parents: 29444
diff changeset
     9
typedef __int64 ssize_t;
33926
f4433f2713d0 encoding: add function to test if a str consists of ASCII characters
Yuya Nishihara <yuya@tcha.org>
parents: 29549
diff changeset
    10
typedef unsigned __int64 uintptr_t;
29521
83147ff53112 compat: provide a declaration of ssize_t, for MS windows
Maciej Fijalkowski <fijall@gmail.com>
parents: 29444
diff changeset
    11
#else
29549
7b22599dcb85 compat: define ssize_t as int on 32bit Windows, silences C4142 warning
Yuya Nishihara <yuya@tcha.org>
parents: 29521
diff changeset
    12
typedef int ssize_t;
33926
f4433f2713d0 encoding: add function to test if a str consists of ASCII characters
Yuya Nishihara <yuya@tcha.org>
parents: 29549
diff changeset
    13
typedef unsigned int uintptr_t;
29521
83147ff53112 compat: provide a declaration of ssize_t, for MS windows
Maciej Fijalkowski <fijall@gmail.com>
parents: 29444
diff changeset
    14
#endif
29444
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    15
typedef signed char int8_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    16
typedef short int16_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    17
typedef long int32_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    18
typedef __int64 int64_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    19
typedef unsigned char uint8_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    20
typedef unsigned short uint16_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    21
typedef unsigned long uint32_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    22
typedef unsigned __int64 uint64_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    23
#else
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    24
#include <stdint.h>
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    25
#endif
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    26
#else
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    27
/* not windows */
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    28
#include <sys/types.h>
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    29
#if defined __BEOS__ && !defined __HAIKU__
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    30
#include <ByteOrder.h>
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    31
#else
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    32
#include <arpa/inet.h>
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    33
#endif
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    34
#include <inttypes.h>
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    35
#endif
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    36
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    37
#if defined __hpux || defined __SUNPRO_C || defined _AIX
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    38
#define inline
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    39
#endif
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    40
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    41
#ifdef __linux
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    42
#define inline __inline
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    43
#endif
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    44
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    45
#endif