1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-13 13:18:06 +03:00

r13577: Move some (possibly system-defined) defines to replace.h

This commit is contained in:
Jelmer Vernooij 2006-02-20 20:40:51 +00:00 committed by Gerald (Jerry) Carter
parent 7dde77942b
commit 2b3d56e153
2 changed files with 18 additions and 16 deletions

View File

@ -162,6 +162,14 @@ int rep_mkstemp(char *temp);
#include <limits.h> #include <limits.h>
#endif #endif
/* The extra casts work around common compiler bugs. */
#define _TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
It is necessary at least when t == time_t. */
#define _TYPE_MINIMUM(t) ((t) (_TYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
#define _TYPE_MAXIMUM(t) ((t) (~ (t) 0 - _TYPE_MINIMUM (t)))
#ifndef HOST_NAME_MAX #ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 64 #define HOST_NAME_MAX 64
#endif #endif
@ -178,4 +186,12 @@ int rep_mkstemp(char *temp);
#define UINT64_MAX ((uint64_t)-1) #define UINT64_MAX ((uint64_t)-1)
#endif #endif
#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif
#ifndef INT32_MAX
#define INT32_MAX _TYPE_MAXIMUM(int32_t)
#endif
#endif #endif

View File

@ -23,31 +23,17 @@
#include "includes.h" #include "includes.h"
#include "system/time.h" #include "system/time.h"
#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif
/* The extra casts work around common compiler bugs. */
#define _TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
It is necessary at least when t == time_t. */
#define _TYPE_MINIMUM(t) ((t) (_TYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
#define _TYPE_MAXIMUM(t) ((t) (~ (t) 0 - _TYPE_MINIMUM (t)))
#ifndef TIME_T_MIN #ifndef TIME_T_MIN
/* we use 0 here, because (time_t)-1 means error */ /* we use 0 here, because (time_t)-1 means error */
#define TIME_T_MIN 0 #define TIME_T_MIN 0
#endif #endif
#ifndef TIME_T_MAX
/* /*
* we use the INT32_MAX here as on 64 bit systems, * we use the INT32_MAX here as on 64 bit systems,
* gmtime() fails with INT64_MAX * gmtime() fails with INT64_MAX
*/ */
#ifndef INT32_MAX
#define INT32_MAX _TYPE_MAXIMUM(int32_t)
#endif
#ifndef TIME_T_MAX
#define TIME_T_MAX MIN(INT32_MAX,_TYPE_MAXIMUM(time_t)) #define TIME_T_MAX MIN(INT32_MAX,_TYPE_MAXIMUM(time_t))
#endif #endif