mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/dl/dl.h (ALIGN_OF): use offsetof().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
196151158f
commit
96ab37015e
2 changed files with 12 additions and 18 deletions
|
@ -1,4 +1,6 @@
|
|||
Fri Feb 10 01:29:05 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Fri Feb 10 01:30:41 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/dl/dl.h (ALIGN_OF): use offsetof().
|
||||
|
||||
* ext/dl/dl.h (DLALIGN): round up at once and get rid of overflow.
|
||||
|
||||
|
|
26
ext/dl/dl.h
26
ext/dl/dl.h
|
@ -134,26 +134,18 @@ extern VALUE rb_cDLSymbol;
|
|||
extern VALUE rb_eDLError;
|
||||
extern VALUE rb_eDLTypeError;
|
||||
|
||||
typedef struct { char c; void *x; } s_voidp;
|
||||
typedef struct { char c; short x; } s_short;
|
||||
typedef struct { char c; int x; } s_int;
|
||||
typedef struct { char c; long x; } s_long;
|
||||
typedef struct { char c; float x; } s_float;
|
||||
typedef struct { char c; double x; } s_double;
|
||||
#if HAVE_LONG_LONG
|
||||
typedef struct { char c; LONG_LONG x; } s_long_long;
|
||||
#endif
|
||||
#define ALIGN_OF(type) offsetof(struct {char align_c; type align_x;}, align_x)
|
||||
|
||||
#define ALIGN_VOIDP (sizeof(s_voidp) - sizeof(void *))
|
||||
#define ALIGN_SHORT (sizeof(s_short) - sizeof(short))
|
||||
#define ALIGN_CHAR (1)
|
||||
#define ALIGN_INT (sizeof(s_int) - sizeof(int))
|
||||
#define ALIGN_LONG (sizeof(s_long) - sizeof(long))
|
||||
#define ALIGN_VOIDP ALIGN_OF(void*)
|
||||
#define ALIGN_SHORT ALIGN_OF(short)
|
||||
#define ALIGN_CHAR ALIGN_OF(char)
|
||||
#define ALIGN_INT ALIGN_OF(int)
|
||||
#define ALIGN_LONG ALIGN_OF(long)
|
||||
#if HAVE_LONG_LONG
|
||||
#define ALIGN_LONG_LONG (sizeof(s_long_long) - sizeof(LONG_LONG))
|
||||
#define ALIGN_LONG_LONG ALIGN_OF(LONG_LONG)
|
||||
#endif
|
||||
#define ALIGN_FLOAT (sizeof(s_float) - sizeof(float))
|
||||
#define ALIGN_DOUBLE (sizeof(s_double) - sizeof(double))
|
||||
#define ALIGN_FLOAT ALIGN_OF(float)
|
||||
#define ALIGN_DOUBLE ALIGN_OF(double)
|
||||
|
||||
#define DLALIGN(ptr,offset,align) \
|
||||
((offset) += ((align) - ((uintptr_t)((char *)(ptr) + (offset))) % (align)) % (align))
|
||||
|
|
Loading…
Reference in a new issue