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/lisp.h | |
| 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/lisp.h')
| -rw-r--r-- | src/lisp.h | 12 |
1 files changed, 3 insertions, 9 deletions
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 |