git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-compat-util.h: adjust for SGI IRIX 6.5

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Aug 18, 2008, 23:05 UTC
Message-ID
<pJRtiHdsP9HbnKMePwHZJe4brRLzVt3u6tqH8mkWqf8@cipher.nrlssc.navy.mil>
In-Reply-To
<giNXZFTxzY3B65dQob7CwvwwfSKlZpw_60oz81RxU5UN3PsTT_3dMQ@cipher.nrlssc.navy.mil>

Don't define _XOPEN_SOURCE Do define _SGI_SOURCE Declare the _xpg5 versions of *snprintf() along with wrapper macros

Defining _XOPEN_SOURCE prevents many of the common functions and macros
from being defined. _Not_ setting _XOPEN_SOURCE, and instead setting
_SGI_SOURCE, provides all of the XPG4, XPG5, BSD, POSIX functions and
declarations, _BUT_ provides a horribly broken snprintf(). The provided
snprintf() can not be worked around using git's compat workaround, since
SGI's vsnprintf() always returns the number of characters written into
the string, instead of -1 which is what git's compat version expects.
SGI does have a working snprintf(), but it is only provided when
_NO_XOPEN5 evaluates to zero, and this only happens if _XOPEN_SOURCE is
defined which, as mentioned above, prevents many other common functions
and defines. The working *snprintf() functions are named _xpg5_vsnprintf()
and _xpg5_snprintf(), so declarations for these two functions were added
to git-compat-util.h and macros were added for vsnprintf and snprintf to
call these versions.
---
 git-compat-util.h |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index cf89cdf..f22707c 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -39,13 +39,14 @@
 /* Approximation of the length of the decimal representation of this type. */
 #define decimal_length(x)	((int)(sizeof(x) * 2.56 + 0.5) + 1)
 
-#if !defined(__APPLE__) && !defined(__FreeBSD__)  && !defined(__USLC__) && !defined(_M_UNIX)
+#if !defined(__APPLE__) && !defined(__FreeBSD__)  && !defined(__USLC__) && !defined(_M_UNIX) && !defined(sgi)
 #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
 #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
 #endif
 #define _ALL_SOURCE 1
 #define _GNU_SOURCE 1
 #define _BSD_SOURCE 1
+#define _SGI_SOURCE 1
 
 #include <unistd.h>
 #include <stdio.h>
@@ -262,6 +263,15 @@ extern int git_snprintf(char *str, size_t maxsize,
 #define vsnprintf git_vsnprintf
 extern int git_vsnprintf(char *str, size_t maxsize,
 			 const char *format, va_list ap);
+#elif defined(sgi)
+extern int      _xpg5_vsnprintf(char * __restrict,
+                        __SGI_LIBC_NAMESPACE_QUALIFIER size_t,
+                        const char * __restrict, /* va_list */ char *);
+#define vsnprintf _xpg5_vsnprintf
+extern int      _xpg5_snprintf(char * __restrict,
+                        __SGI_LIBC_NAMESPACE_QUALIFIER size_t,
+                        const char * __restrict, ...);
+#define snprintf _xpg5_snprintf
 #endif
 
 #ifdef __GLIBC_PREREQ
-- 
1.6.0.13.ge1c8
Previous: Brandon CaseyNext: Brandon Casey
Message 3 of 28 in “[FYI] How I compile on IRIX 6.5 with the MIPSpro compiler and ksh”
  1. Brandon CaseyAug 18, 2008
  2. Makefile: add section for SGI IRIXBrandon Casey, Aug 18, 2008
  3. git-compat-util.h: adjust for SGI IRIX 6.5Brandon Casey, Aug 18, 2008
  4. unpack-trees.c: work around run-time array initialization flaw on IRIX 6.5Brandon Casey, Aug 18, 2008
  5. templates/Makefile: work around SGI install which assumes / if ROOT not definedBrandon Casey, Aug 18, 2008
  6. Junio C HamanoAug 18, 2008
  7. Brandon CaseyAug 19, 2008
  8. templates/Makefile: install is unnecessary, just use mkdir -pBrandon Casey, Aug 22, 2008
  9. test-lib.sh: work around ksh's trap shortcomingsBrandon Casey, Aug 18, 2008
  10. Junio C HamanoAug 18, 2008
  11. Brandon CaseyAug 19, 2008
  12. Junio C HamanoAug 19, 2008
  13. Brandon CaseyAug 19, 2008
  14. Brandon CaseyAug 19, 2008
  15. Brandon CaseyAug 20, 2008
  16. Mike RalphsonAug 20, 2008
  17. t1002-read-tree-m-u-2way.sh: use 'git diff -U0' rather than 'diff -U0'Brandon Casey, Aug 18, 2008
  18. t9301-fast-export.sh: don't unset config variable while we're skipping test 4Brandon Casey, Aug 18, 2008
  19. Junio C HamanoAug 19, 2008
  20. Brandon CaseyAug 19, 2008
  21. t9301-fast-export: move unset of config variable into its own test functionBrandon Casey, Aug 22, 2008
  22. Junio C HamanoAug 22, 2008
  23. Junio C HamanoAug 22, 2008
  24. Johannes SixtAug 22, 2008
  25. Junio C HamanoAug 22, 2008
  26. Brandon CaseyAug 18, 2008
  27. Boyd Lynn GerberAug 19, 2008
  28. Brandon CaseyAug 19, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.