diff mbox

[fixincludes] Wrap fcntl.h on AIX

Message ID CAGWvnyk0_5LFuw2fuM0ixY7s=Kxn+6NjxpeYRbC3H50OkAx7ZQ@mail.gmail.com
State New
Headers show

Commit Message

David Edelsohn Sept. 29, 2012, 4:45 p.m. UTC
AIX fcntl.h redefines "open", which conflicts with g++ fstream header.
 This patch wraps fcntl.h to use aliases in the same way that stdio.h
currently is wrapped.

Okay?

Thanks, David

* inclhack.def (AAB_aix_fcntl): New fix.
* fixincl.x: Regenerate.
* tests/base/fcntl.h [AAB_AIX_FCNTL_CHECK]: New.

Comments

Bruce Korb Sept. 29, 2012, 6 p.m. UTC | #1
Does "make check" complain if a replacement/wrap fix doesn't have a test?
If so, I'll be fixing it when I have time -- towards the end of October.
(The patch I sent a few days ago ought to do it, but I've not fully tested yet.)
Anyway, looks pretty reasonable to me...

On Sat, Sep 29, 2012 at 9:45 AM, David Edelsohn <dje.gcc@gmail.com> wrote:
> AIX fcntl.h redefines "open", which conflicts with g++ fstream header.
>  This patch wraps fcntl.h to use aliases in the same way that stdio.h
> currently is wrapped.
>
> Okay?

> +    test-text = ''; /* no way to test */
David Edelsohn Sept. 29, 2012, 7:29 p.m. UTC | #2
On Sat, Sep 29, 2012 at 2:00 PM, Bruce Korb <bkorb@gnu.org> wrote:
> Does "make check" complain if a replacement/wrap fix doesn't have a test?
> If so, I'll be fixing it when I have time -- towards the end of October.
> (The patch I sent a few days ago ought to do it, but I've not fully tested yet.)
> Anyway, looks pretty reasonable to me...

The stdio fix already includes the same test.

- David
diff mbox

Patch

Index: inclhack.def
===================================================================
--- inclhack.def        (revision 191846)
+++ inclhack.def        (working copy)
@@ -65,6 +65,45 @@ 
 };


+/* On AIX when _LARGE_FILES is defined fcntl.h defines open to
+ * open64 and creat to creat64.  This fixes fcntl.h to
+ * undef those defines and use __asm__ to alias the symbols if
+ * building with g++ and -D_LARGE_FILES
+ */
+fix = {
+    hackname  = AAB_aix_fcntl;
+    files     = fcntl.h;
+    select    = "define open[ \t]open64";
+    mach      = "*-*-aix*";
+    test-text = ''; /* no way to test */
+
+    c_fix     = wrap;
+
+    c_fix_arg = "";
+
+    c_fix_arg = <<- _EOArg_
+
+       #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
+       #define __need__aix_fcntl_h_fix
+       #ifdef __need__aix_fcntl_h_fix
+       #undef open
+       #undef creat
+       #undef openat
+       /* Alias the symbols using asm */
+       extern "C" {
+       extern int open(const char *, int, ...) __asm__("open64");
+       extern int creat(const char *, mode_t) __asm__("creat64");
+       #if (_XOPEN_SOURCE >= 700)
+       extern int openat(int, const char *, int, ...) __asm__("open64at");
+       #endif
+       }
+       #endif
+       #endif
+
+       _EOArg_;
+};
+
+
 /*
  *  On Mac OS 10.3.9, the 'long double' functions are available in
  *  libSystem, but are not prototyped in math.h.