Ignore:
Timestamp:
Apr 25, 2007, 9:44:55 AM (14 years ago)
Author:
Paul Smedley
Message:

Code updated to Samba 3.0.25rc2 level

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/samba/source/lib/replace/replace.h

    r1 r30  
    8080#endif
    8181
     82/**
     83  this is a warning hack. The idea is to use this everywhere that we
     84  get the "discarding const" warning from gcc. That doesn't actually
     85  fix the problem of course, but it means that when we do get to
     86  cleaning them up we can do it by searching the code for
     87  discard_const.
     88
     89  It also means that other error types aren't as swamped by the noise
     90  of hundreds of const warnings, so we are more likely to notice when
     91  we get new errors.
     92
     93  Please only add more uses of this macro when you find it
     94  _really_ hard to fix const warnings. Our aim is to eventually use
     95  this function in only a very few places.
     96
     97  Also, please call this via the discard_const_p() macro interface, as that
     98  makes the return type safe.
     99*/
     100#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
     101
     102/** Type-safe version of discard_const */
     103#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
     104
    82105#ifndef HAVE_STRERROR
    83106extern char *sys_errlist[];
     
    138161#ifndef HAVE_SETENV
    139162#define setenv rep_setenv
    140 int rep_setenv(const char *name, const char *value, int overwrite);
     163int rep_setenv(const char *name, const char *value, int overwrite);
     164#else
     165#ifndef HAVE_SETENV_DECL
     166int setenv(const char *name, const char *value, int overwrite);
     167#endif
     168#endif
     169
     170#ifndef HAVE_UNSETENV
     171#define unsetenv rep_unsetenv
     172int rep_unsetenv(const char *name);
    141173#endif
    142174
     
    182214
    183215#ifndef HAVE_INITGROUPS
    184 #define ftruncate rep_ftruncate
     216#define initgroups rep_initgroups
    185217int rep_initgroups(char *name, gid_t id);
    186218#endif
     
    276308#endif
    277309
     310#ifdef REPLACE_STRPTIME
     311#define strptime rep_strptime
     312struct tm;
     313char *rep_strptime(const char *buf, const char *format, struct tm *tm);
     314#endif
     315
    278316/* Load header file for dynamic linking stuff */
    279317#ifdef HAVE_DLFCN_H
     
    402440#endif
    403441
     442#ifndef _STRINGSTRING
     443#define __STRINGSTRING(x) __STRING(x)
     444#endif
     445
     446#ifndef __LINESTR__
     447#define __LINESTR__ __STRINGSTRING(__LINE__)
     448#endif
     449
     450#ifndef __location__
     451#define __location__ __FILE__ ":" __LINESTR__
     452#endif
     453
     454/**
     455 * zero a structure
     456 */
     457#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
     458
     459/**
     460 * zero a structure given a pointer to the structure
     461 */
     462#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
     463
     464/**
     465 * zero a structure given a pointer to the structure - no zero check
     466 */
     467#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x)))
     468
     469/* zero an array - note that sizeof(array) must work - ie. it must not be a
     470   pointer */
     471#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x))
     472
     473/**
     474 * work out how many elements there are in a static array
     475 */
     476#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
     477
     478/**
     479 * pointer difference macro
     480 */
     481#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2)))
     482
    404483#if MMAP_BLACKLIST
    405484#undef HAVE_MMAP
Note: See TracChangeset for help on using the changeset viewer.