X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Fmph.h;h=8a61999942641e4e81bb5c953e5c04f494510c4f;hb=d094687a029410a4b53927a96ad7eef29e4ba95c;hp=56f83e52b16e6c832bab0b8ec843fd640c2b3abb;hpb=53e266903ec6b2d822cf5b0c566f6374df5307a4;p=mono.git diff --git a/support/mph.h b/support/mph.h index 56f83e52b16..8a619999426 100644 --- a/support/mph.h +++ b/support/mph.h @@ -27,6 +27,7 @@ #include +#include /* offsetof */ #include /* LONG_MAX, ULONG_MAX */ #include /* for ERANGE */ #include /* for g* types, etc. */ @@ -35,7 +36,7 @@ #include /* for SIZE_MAX */ #endif -#if __APPLE__ || __BSD__ || __FreeBSD__ +#if __APPLE__ || __BSD__ || __FreeBSD__ || __OpenBSD__ #define MPH_ON_BSD #endif @@ -45,11 +46,15 @@ #define MPH_INTERNAL #endif -#if defined (PLATFORM_WIN32) && !defined (EOVERFLOW) -#define EOVERFLOW 75 -#endif /* def PLATFORM_WIN32 && ndef EOVERFLOW */ +#if !defined(EOVERFLOW) +# if defined(HOST_WIN32) +# define EOVERFLOW 75 +# elif defined(__OpenBSD__) +# define EOVERFLOW 87 +# endif +#endif /* !defined(EOVERFLOW) */ -#if !defined (PLATFORM_WIN32) +#if !defined (HOST_WIN32) /* * Solaris doesn't define these BSD values, and if they're not present then @@ -79,7 +84,7 @@ #define XATTR_AUTO 0 #endif /* ndef XATTR_AUTO */ -#endif /* ndef PLATFORM_WIN32 */ +#endif /* ndef HOST_WIN32 */ typedef gint64 mph_blkcnt_t; typedef gint64 mph_blksize_t; @@ -170,6 +175,13 @@ typedef gint64 suseconds_t; #define mph_return_if_time_t_overflow(var) mph_return_if_long_overflow(var) +#define mph_return_if_val_in_list5(var,a,b,c,d,e) \ + do { \ + int v = (var); \ + if (v == a || v == b || v == c || v == d || v == e) \ + return -1; \ + } while (0) + /* * Helper function for functions which use ERANGE (such as getpwnam_r and * getgrnam_r). These functions accept buffers which are dynamically @@ -191,10 +203,20 @@ recheck_range (int ret) return 0; } +typedef unsigned int mph_string_offset_t; + +enum { + MPH_STRING_OFFSET_PTR = 0x0, + MPH_STRING_OFFSET_ARRAY = 0x1, + MPH_STRING_OFFSET_MASK = 0x1 +}; + +#define MPH_STRING_OFFSET(type,member,kind) ((offsetof(type,member) << 1) | kind) + MPH_INTERNAL char* _mph_copy_structure_strings ( - void *to, const size_t *to_offsets, - const void *from, const size_t *from_offsets, + void *to, const mph_string_offset_t *to_offsets, + const void *from, const mph_string_offset_t *from_offsets, size_t num_strings); #endif /* ndef INC_mph_H */