Remove offsetof definition

Started by Peter Eisentrautover 3 years ago2 messages
#1Peter Eisentraut
peter.eisentraut@enterprisedb.com
1 attachment(s)

More portability cruft cleanup: Our own definition of offsetof() was
only relevant for ancient systems and can surely be removed.

Attachments:

0001-Remove-offsetof-definition.patchtext/plain; charset=UTF-8; name=0001-Remove-offsetof-definition.patchDownload
From 6c09404772ad7163e2f69b60f9adc61a151173f5 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 22 Aug 2022 16:14:45 +0200
Subject: [PATCH] Remove offsetof definition

This was only needed to deal with some ancient and no longer supported
systems.
---
 src/include/c.h | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/src/include/c.h b/src/include/c.h
index dfc366b026..a381f9a6c4 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -30,7 +30,7 @@
  *		2)		bool, true, false
  *		3)		standard system types
  *		4)		IsValid macros for system types
- *		5)		offsetof, lengthof, alignment
+ *		5)		lengthof, alignment
  *		6)		assertions
  *		7)		widely useful macros
  *		8)		random stuff
@@ -703,20 +703,9 @@ typedef NameData *Name;
 
 
 /* ----------------------------------------------------------------
- *				Section 5:	offsetof, lengthof, alignment
+ *				Section 5:	lengthof, alignment
  * ----------------------------------------------------------------
  */
-/*
- * offsetof
- *		Offset of a structure/union field within that structure/union.
- *
- *		XXX This is supposed to be part of stddef.h, but isn't on
- *		some systems (like SunOS 4).
- */
-#ifndef offsetof
-#define offsetof(type, field)	((long) &((type *)0)->field)
-#endif							/* offsetof */
-
 /*
  * lengthof
  *		Number of elements in an array.
-- 
2.37.1

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#1)
Re: Remove offsetof definition

Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:

More portability cruft cleanup: Our own definition of offsetof() was
only relevant for ancient systems and can surely be removed.

+1, it's required by C99.

regards, tom lane