diff options
| author | Andreas Schwab | 2010-07-11 20:34:43 +0200 |
|---|---|---|
| committer | Andreas Schwab | 2010-07-11 20:34:43 +0200 |
| commit | 89887d672aded197a2be95f3d8a6d5bdcb19eb58 (patch) | |
| tree | fefa168f1ddbc3c0f04f3e891cc20007a65e11a4 /src | |
| parent | ae96d47a63b32aa752bc65ce08f8b7b7254db3e6 (diff) | |
| download | emacs-89887d672aded197a2be95f3d8a6d5bdcb19eb58.tar.gz emacs-89887d672aded197a2be95f3d8a6d5bdcb19eb58.zip | |
Use offsetof instead of own definition
* lisp.h: Include <stddef.h>.
(OFFSETOF): Don't define.
(VECSIZE): Use offsetof instead of OFFSETOF.
(PSEUDOVECSIZE): Likewise.
* process.c (conv_sockaddr_to_lisp): Likewise.
* alloc.c: Don't include <stddef.h>.
* buffer.h (PER_BUFFER_VAR_OFFSET): Use offsetof.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/alloc.c | 4 | ||||
| -rw-r--r-- | src/buffer.h | 2 | ||||
| -rw-r--r-- | src/lisp.h | 12 | ||||
| -rw-r--r-- | src/process.c | 4 |
5 files changed, 14 insertions, 16 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 48ba055280c..2e5ea4658dc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,13 @@ | |||
| 1 | 2010-07-11 Andreas Schwab <schwab@linux-m68k.org> | 1 | 2010-07-11 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 2 | ||
| 3 | * lisp.h: Include <stddef.h>. | ||
| 4 | (OFFSETOF): Don't define. | ||
| 5 | (VECSIZE): Use offsetof instead of OFFSETOF. | ||
| 6 | (PSEUDOVECSIZE): Likewise. | ||
| 7 | * process.c (conv_sockaddr_to_lisp): Likewise. | ||
| 8 | * alloc.c: Don't include <stddef.h>. | ||
| 9 | * buffer.h (PER_BUFFER_VAR_OFFSET): Use offsetof. | ||
| 10 | |||
| 3 | * process.c: Remove obsolete comment. | 11 | * process.c: Remove obsolete comment. |
| 4 | 12 | ||
| 5 | 2010-07-11 Chong Yidong <cyd@stupidchicken.com> | 13 | 2010-07-11 Chong Yidong <cyd@stupidchicken.com> |
diff --git a/src/alloc.c b/src/alloc.c index 02c6022e475..5c860bc1f8e 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -23,10 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 23 | #include <limits.h> /* For CHAR_BIT. */ | 23 | #include <limits.h> /* For CHAR_BIT. */ |
| 24 | #include <setjmp.h> | 24 | #include <setjmp.h> |
| 25 | 25 | ||
| 26 | #ifdef STDC_HEADERS | ||
| 27 | #include <stddef.h> /* For offsetof, used by PSEUDOVECSIZE. */ | ||
| 28 | #endif | ||
| 29 | |||
| 30 | #ifdef ALLOC_DEBUG | 26 | #ifdef ALLOC_DEBUG |
| 31 | #undef INLINE | 27 | #undef INLINE |
| 32 | #endif | 28 | #endif |
diff --git a/src/buffer.h b/src/buffer.h index 8e4e5d569ae..339e7d9bb6d 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -954,7 +954,7 @@ extern int last_per_buffer_idx; | |||
| 954 | from the start of a buffer structure. */ | 954 | from the start of a buffer structure. */ |
| 955 | 955 | ||
| 956 | #define PER_BUFFER_VAR_OFFSET(VAR) \ | 956 | #define PER_BUFFER_VAR_OFFSET(VAR) \ |
| 957 | ((char *) &((struct buffer *)0)->VAR - (char *) ((struct buffer *)0)) | 957 | offsetof (struct buffer, VAR) |
| 958 | 958 | ||
| 959 | /* Return the index of buffer-local variable VAR. Each per-buffer | 959 | /* Return the index of buffer-local variable VAR. Each per-buffer |
| 960 | variable has an index > 0 associated with it, except when it always | 960 | variable has an index > 0 associated with it, except when it always |
diff --git a/src/lisp.h b/src/lisp.h index d59b75caa2f..656e8fbb624 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -22,6 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 22 | #define EMACS_LISP_H | 22 | #define EMACS_LISP_H |
| 23 | 23 | ||
| 24 | #include <stdarg.h> | 24 | #include <stdarg.h> |
| 25 | #include <stddef.h> | ||
| 25 | 26 | ||
| 26 | /* Use the configure flag --enable-checking[=LIST] to enable various | 27 | /* Use the configure flag --enable-checking[=LIST] to enable various |
| 27 | types of run time checks for Lisp objects. */ | 28 | types of run time checks for Lisp objects. */ |
| @@ -784,13 +785,6 @@ struct Lisp_String | |||
| 784 | unsigned char *data; | 785 | unsigned char *data; |
| 785 | }; | 786 | }; |
| 786 | 787 | ||
| 787 | #ifdef offsetof | ||
| 788 | #define OFFSETOF(type,field) offsetof(type,field) | ||
| 789 | #else | ||
| 790 | #define OFFSETOF(type,field) \ | ||
| 791 | ((int)((char*)&((type*)0)->field - (char*)0)) | ||
| 792 | #endif | ||
| 793 | |||
| 794 | struct Lisp_Vector | 788 | struct Lisp_Vector |
| 795 | { | 789 | { |
| 796 | EMACS_UINT size; | 790 | EMACS_UINT size; |
| @@ -801,7 +795,7 @@ struct Lisp_Vector | |||
| 801 | /* If a struct is made to look like a vector, this macro returns the length | 795 | /* If a struct is made to look like a vector, this macro returns the length |
| 802 | of the shortest vector that would hold that struct. */ | 796 | of the shortest vector that would hold that struct. */ |
| 803 | #define VECSIZE(type) ((sizeof (type) \ | 797 | #define VECSIZE(type) ((sizeof (type) \ |
| 804 | - OFFSETOF (struct Lisp_Vector, contents[0]) \ | 798 | - offsetof (struct Lisp_Vector, contents[0]) \ |
| 805 | + sizeof(Lisp_Object) - 1) /* round up */ \ | 799 | + sizeof(Lisp_Object) - 1) /* round up */ \ |
| 806 | / sizeof (Lisp_Object)) | 800 | / sizeof (Lisp_Object)) |
| 807 | 801 | ||
| @@ -809,7 +803,7 @@ struct Lisp_Vector | |||
| 809 | at the end and we need to compute the number of Lisp_Object fields (the | 803 | at the end and we need to compute the number of Lisp_Object fields (the |
| 810 | ones that the GC needs to trace). */ | 804 | ones that the GC needs to trace). */ |
| 811 | #define PSEUDOVECSIZE(type, nonlispfield) \ | 805 | #define PSEUDOVECSIZE(type, nonlispfield) \ |
| 812 | ((OFFSETOF(type, nonlispfield) - OFFSETOF(struct Lisp_Vector, contents[0])) \ | 806 | ((offsetof(type, nonlispfield) - offsetof(struct Lisp_Vector, contents[0])) \ |
| 813 | / sizeof (Lisp_Object)) | 807 | / sizeof (Lisp_Object)) |
| 814 | 808 | ||
| 815 | /* A char-table is a kind of vectorlike, with contents are like a | 809 | /* A char-table is a kind of vectorlike, with contents are like a |
diff --git a/src/process.c b/src/process.c index ed31657b01c..0fec550ad8f 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -2263,7 +2263,7 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, int len) | |||
| 2263 | /* Workaround for a bug in getsockname on BSD: Names bound to | 2263 | /* Workaround for a bug in getsockname on BSD: Names bound to |
| 2264 | sockets in the UNIX domain are inaccessible; getsockname returns | 2264 | sockets in the UNIX domain are inaccessible; getsockname returns |
| 2265 | a zero length name. */ | 2265 | a zero length name. */ |
| 2266 | if (len < OFFSETOF (struct sockaddr, sa_family) + sizeof (sa->sa_family)) | 2266 | if (len < offsetof (struct sockaddr, sa_family) + sizeof (sa->sa_family)) |
| 2267 | return empty_unibyte_string; | 2267 | return empty_unibyte_string; |
| 2268 | 2268 | ||
| 2269 | switch (sa->sa_family) | 2269 | switch (sa->sa_family) |
| @@ -2303,7 +2303,7 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, int len) | |||
| 2303 | } | 2303 | } |
| 2304 | #endif | 2304 | #endif |
| 2305 | default: | 2305 | default: |
| 2306 | len -= OFFSETOF (struct sockaddr, sa_family) + sizeof (sa->sa_family); | 2306 | len -= offsetof (struct sockaddr, sa_family) + sizeof (sa->sa_family); |
| 2307 | address = Fcons (make_number (sa->sa_family), | 2307 | address = Fcons (make_number (sa->sa_family), |
| 2308 | Fmake_vector (make_number (len), Qnil)); | 2308 | Fmake_vector (make_number (len), Qnil)); |
| 2309 | p = XVECTOR (XCDR (address)); | 2309 | p = XVECTOR (XCDR (address)); |