[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ggi-develop
Subject:    Re: [ggi-develop] libgii: addition of integer type capable for holding object pointers
From:       "Christoph Egger" <Christoph_Egger () gmx ! de>
Date:       2004-08-03 19:59:54
Message-ID: 9149.1091563194 () www38 ! gmx ! net
[Download RAW message or body]

This is a MIME encapsulated multipart message -
please use a MIME-compliant e-mail program to open it.

Dies ist eine mehrteilige Nachricht im MIME-Format -
bitte verwenden Sie zum Lesen ein MIME-konformes Mailprogramm.


> > On Tue, 3 Aug 2004, Christoph Egger wrote:
> > > Also note that size_t is unsigned. ssize_t is not available on all
> > > platforms.
> > > intptr_t is signed and uintptr_t is unsigned.
> > > These are important nuances when casting.
> > > 
> > > Do you think we should provide a ggi_intptr / ggi_uintptr instead?
> > 
> > Yes, but I think putting "int" in the names is bad, even though POSIX 
> > does it.  It makes it sound like a pointer-to-an-int, rather than a 
> > void *.
> 
> Well, that's actually the case. It is a integer type always be big enough
> to hold object pointers.
> With this datatype we can clean up the 64bit issues of the 64bit SWAR
> implementation in
> libggi/display/linear_16/crossblit.c

Peter and I discussed this on IRC and we came to this decision:

- make sure intptr_t / uintptr_t is always available
- declare our own intptr_t / uintptr_t on platforms where not available
- don't export intptr_t / uintptr_t
- add an internal header containing the types we need.

The attached patch adds a <ggi/internal/gg_types.h>
intptr_t / uintptr_t is defined on platforms where not available.

According to http://www.schweikhardt.net/identifiers.html
these datatypes are new in ANSI/ISO C99 and are available
through <stdint.h>

-- 
CU,

Christoph Egger
E-Mail: Christoph_Egger@gmx.de

NEU: WLAN-Router für 0,- EUR* - auch für DSL-Wechsler!
GMX DSL = supergünstig & kabellos http://www.gmx.net/de/go/dsl
["libgii_devel_intptr.diff" (application/octet-stream)]

Index: configure.in
===================================================================
RCS file: /cvsroot/ggi/ggi-core/libgii/configure.in,v
retrieving revision 1.95
diff -u -p -r1.95 configure.in
--- configure.in	5 Jun 2004 00:49:44 -0000	1.95
+++ configure.in	3 Aug 2004 19:56:51 -0000
@@ -825,6 +825,8 @@ AC_SUBST(GGI_8)
 AC_SUBST(GGI_16)
 AC_SUBST(GGI_32)
 AC_SUBST(GGI_64)
+AC_SUBST(GGI_INTPTR)
+AC_SUBST(GGI_UINTPTR)
 AC_SUBST(GGI_DEFINE_INT64)
 AC_SUBST(GGI_ENDIAN)
 AC_SUBST(GG_ATEXIT)
@@ -913,6 +915,7 @@ include/ggi/system.h
 include/ggi/Makefile
 include/ggi/input/Makefile
 include/ggi/internal/Makefile
+include/ggi/internal/gg_types.h
 doc/Makefile
 doc/man/Makefile
 regress/Makefile
Index: include/ggi/internal/Makefile.am
===================================================================
RCS file: /cvsroot/ggi/ggi-core/libgii/include/ggi/internal/Makefile.am,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile.am
--- include/ggi/internal/Makefile.am	4 Jul 2003 22:38:28 -0000	1.5
+++ include/ggi/internal/Makefile.am	3 Aug 2004 19:56:51 -0000
@@ -1,4 +1,4 @@
 internincludedir = ${includedir}/ggi/internal
-interninclude_HEADERS = gii.h gii-dl.h
+interninclude_HEADERS = gii.h gii-dl.h gg_types.h
 
 noinst_HEADERS = gii_target.h gii_debug.h gg.h
Index: include/ggi/internal/gg_types.h.in
===================================================================
RCS file: include/ggi/internal/gg_types.h.in
diff -N include/ggi/internal/gg_types.h.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ include/ggi/internal/gg_types.h.in	3 Aug 2004 19:56:51 -0000
@@ -0,0 +1,42 @@
+/* $Id: gg.h,v 1.8 2004/03/29 15:29:18 pekberg Exp $
+******************************************************************************
+  
+   LibGG - internal data types
+  
+   Copyright (C) 2004 Christoph Egger	[Christoph_Egger@gmx.de]
+
+   Permission is hereby granted, free of charge, to any person obtaining a
+   copy of this software and associated documentation files (the "Software"),
+   to deal in the Software without restriction, including without limitation
+   the rights to use, copy, modify, merge, publish, distribute, sublicense,
+   and/or sell copies of the Software, and to permit persons to whom the
+   Software is furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+   THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+   IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+   
+******************************************************************************
+*/
+
+#ifndef _GGI_INTERNAL_GG_TYPES_H
+#define _GGI_INTERNAL_GG_TYPES_H
+
+
+/* POSIX: 7.18.1.4 Integer types capable of holding object pointers */
+
+@GGI_INTPTR@
+@GGI_UINTPTR@
+
+
+__BEGIN_DECLS
+
+__END_DECLS
+
+#endif /* _GGI_INTERNAL_GG_TYPES_H */
Index: m4/checktypes.m4
===================================================================
RCS file: /cvsroot/ggi/ggi-core/libgii/m4/checktypes.m4,v
retrieving revision 1.3
diff -u -p -r1.3 checktypes.m4
--- m4/checktypes.m4	29 Feb 2004 19:32:22 -0000	1.3
+++ m4/checktypes.m4	3 Aug 2004 19:56:51 -0000
@@ -8,6 +8,7 @@ AC_CHECK_SIZEOF(short, 2)
 AC_CHECK_SIZEOF(int, 4)
 AC_CHECK_SIZEOF(long, 4)
 AC_CHECK_SIZEOF(long long, 8)
+AC_CHECK_SIZEOF(void *, 8)
 
 if test "x$cross_compiling" = "xyes"; then
   AC_MSG_WARN([
@@ -17,6 +18,9 @@ if test "x$cross_compiling" = "xyes"; th
 ])
 fi
 
+dnl POSIX: 7.18.1.4 Integer types capable of holding object pointers
+AC_CHECK_TYPES([intptr_t, uintptr_t])
+
 
 if test "$ac_cv_sizeof_int" = "1"; then
   GGI_8="int"
@@ -93,4 +97,43 @@ else
   AC_MSG_RESULT(Using type $GGI_64 for 64-bit integers)
 fi
 
+
+dnl POSIX: 7.18.1.4 Integer types capable of holding object pointers
+
+if test "$ac_cv_type_intptr_t" = "yes"; then
+  GGI_INTPTR="/* This platform defines intptr_t in <stdint.h> */"
+else
+  GGI_INTPTR="#error There's no intptr_t datatype for this platform"
+  if test "$ac_cv_sizeof_void_p" = "1"; then
+    GGI_INTPTR="typedef ggi_intptr           signed $GGI_8"
+  fi
+  if test "$ac_cv_sizeof_void_p" = "2"; then
+    GGI_INTPTR="typedef ggi_intptr           signed $GGI_16"
+  fi
+  if test "$ac_cv_sizeof_void_p" = "4"; then
+    GGI_INTPTR="typedef ggi_intptr           signed $GGI_32"
+  fi
+  if test "$ac_cv_sizeof_void_p" = "8"; then
+    GGI_INTPTR="typedef ggi_intptr           signed $GGI_64"
+  fi
+fi
+
+if test "$ac_cv_type_uintptr_t" = "yes"; then
+  GGI_UINTPTR="/* This platform defines uintptr_t in <stdint.h> */"
+else
+  GGI_UINTPTR="#error There's no uintptr_t datatype for this platform"
+  if test "$ac_cv_sizeof_void_p" = "1"; then
+    GGI_UINTPTR="typedef ggi_uintptr       unsigned $GGI_8"
+  fi
+  if test "$ac_cv_sizeof_void_p" = "2"; then
+    GGI_UINTPTR="typedef ggi_uintptr       unsigned $GGI_16"
+  fi
+  if test "$ac_cv_sizeof_void_p" = "4"; then
+    GGI_UINTPTR="typedef ggi_uintptr       unsigned $GGI_32"
+  fi
+  if test "$ac_cv_sizeof_void_p" = "8"; then
+    GGI_UINTPTR="typedef ggi_uintptr       unsigned $GGI_64"
+  fi
+fi
+
 ])

-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
ggi-develop mailing list
ggi-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ggi-develop

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic