zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Errors compiling on HP-UX with HP's compiler
@ 2010-12-20  6:00 Paul Ackersviller
  2010-12-20  8:57 ` Vincent Lefevre
  2010-12-20 10:07 ` Peter Stephenson
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Ackersviller @ 2010-12-20  6:00 UTC (permalink / raw)
  To: zsh-workers

I must be using gcc more often than not to have just run across this.
HP's compiler, I think rightly, refuses to do arithmetic on these two
void pointers.  Does gcc treat them as char * for that purpose?
The casts can obviously be done without.

Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.251
diff -u -r1.251 utils.c
--- Src/utils.c 6 Dec 2010 19:34:33 -0000       1.251
+++ Src/utils.c 20 Dec 2010 03:41:01 -0000
@@ -2272,12 +2272,12 @@

 /**/
 mod_export ssize_t
-read_loop(int fd, void *buf, size_t len)
+read_loop(int fd, char *buf, size_t len)
 {
     ssize_t got = len;

     while (1) {
-       ssize_t ret = read(fd, buf, len);
+       ssize_t ret = read(fd, (void *) buf, len);
        if (ret == len)
            break;
        if (ret <= 0) {
@@ -2298,12 +2298,12 @@

 /**/
 mod_export ssize_t
-write_loop(int fd, const void *buf, size_t len)
+write_loop(int fd, const char *buf, size_t len)
 {
     ssize_t wrote = len;

     while (1) {
-       ssize_t ret = write(fd, buf, len);
+       ssize_t ret = write(fd, (void *) buf, len);
        if (ret == len)
            break;
        if (ret < 0) {
@@ -2407,7 +2407,7 @@
        zbeep();
     }
     if (c >= 0)
-       write_loop(SHTTY, &c, 1);
+       write_loop(SHTTY, (char *) &c, 1);
     if (nl)
        write_loop(SHTTY, "\n", 1);


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: Errors compiling on HP-UX with HP's compiler
  2010-12-20  6:00 PATCH: Errors compiling on HP-UX with HP's compiler Paul Ackersviller
@ 2010-12-20  8:57 ` Vincent Lefevre
  2010-12-20 10:07 ` Peter Stephenson
  1 sibling, 0 replies; 3+ messages in thread
From: Vincent Lefevre @ 2010-12-20  8:57 UTC (permalink / raw)
  To: zsh-workers

On 2010-12-20 06:00:37 +0000, Paul Ackersviller wrote:
> I must be using gcc more often than not to have just run across this.
> HP's compiler, I think rightly, refuses to do arithmetic on these two
> void pointers.  Does gcc treat them as char * for that purpose?

This is a well-known GCC extension:

5.21 Arithmetic on `void'- and Function-Pointers
================================================

In GNU C, addition and subtraction operations are supported on pointers
to `void' and on pointers to functions.  This is done by treating the
size of a `void' or of a function as 1.

 A consequence of this is that `sizeof' is also allowed on `void' and
on function types, and returns 1.

 The option `-Wpointer-arith' requests a warning if these extensions
are used.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: Errors compiling on HP-UX with HP's compiler
  2010-12-20  6:00 PATCH: Errors compiling on HP-UX with HP's compiler Paul Ackersviller
  2010-12-20  8:57 ` Vincent Lefevre
@ 2010-12-20 10:07 ` Peter Stephenson
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2010-12-20 10:07 UTC (permalink / raw)
  To: zsh-workers

On Mon, 20 Dec 2010 06:00:37 +0000
Paul Ackersviller <pda@sdf.lonestar.org> wrote:
> I must be using gcc more often than not to have just run across this.
> HP's compiler, I think rightly, refuses to do arithmetic on these two
> void pointers.  Does gcc treat them as char * for that purpose?
> The casts can obviously be done without.

Thanks, we should really have been picked that up by now...

Some older systems used char * in read() and write(), and in fact
there's a definition in prototypes.h that's somewhat out of date to cope
with that.  I wouldn't be at all surprised if it didn't compile on any
such system any more, but it might as well be left open.  Given that
write_loop() and read_loop() now always take char *, and a char * will
be converted to a void * without any problem, I think I'll remove the
outdated type definitions and do without the casts...

Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.116
diff -p -u -r1.116 init.c
--- Src/init.c	15 Jul 2010 18:44:13 -0000	1.116
+++ Src/init.c	20 Dec 2010 10:02:04 -0000
@@ -1380,7 +1380,7 @@ VA_DCL
 	pptbuf = unmetafy(promptexpand(lp ? *lp : NULL, 0, NULL, NULL,
 				       NULL),
 			  &pptlen);
-	write_loop(2, (WRITE_ARG_2_T)pptbuf, pptlen);
+	write_loop(2, pptbuf, pptlen);
 	free(pptbuf);
 
 	ret = shingetline();
Index: Src/input.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/input.c,v
retrieving revision 1.20
diff -p -u -r1.20 input.c
--- Src/input.c	25 Mar 2010 14:03:51 -0000	1.20
+++ Src/input.c	20 Dec 2010 10:02:04 -0000
@@ -260,7 +260,7 @@ inputline(void)
 	    int pptlen;
 	    pptbuf = unmetafy(promptexpand(ingetcpmptl ? *ingetcpmptl : NULL,
 					   0, NULL, NULL, NULL), &pptlen);
-	    write_loop(2, (WRITE_ARG_2_T)pptbuf, pptlen);
+	    write_loop(2, pptbuf, pptlen);
 	    free(pptbuf);
 	}
 	ingetcline = shingetline();
Index: Src/prototypes.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/prototypes.h,v
retrieving revision 1.4
diff -p -u -r1.4 prototypes.h
--- Src/prototypes.h	13 Apr 2001 16:29:28 -0000	1.4
+++ Src/prototypes.h	20 Dec 2010 10:02:04 -0000
@@ -44,13 +44,6 @@ extern int tputs _((char *cp, int affcnt
 
 /* MISSING PROTOTYPES FOR VARIOUS OPERATING SYSTEMS */
 
-/* HP/UX 9 c89 */
-#if defined(__hpux) && defined(_XPG3) && !defined(_POSIX1_1988)
-# define WRITE_ARG_2_T void *
-#else
-# define WRITE_ARG_2_T char *
-#endif
-
 #if defined(__hpux) && defined(_HPUX_SOURCE) && !defined(_XPG4_EXTENDED)
 # define SELECT_ARG_2_T int *
 #else
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.251
diff -p -u -r1.251 utils.c
--- Src/utils.c	6 Dec 2010 19:34:33 -0000	1.251
+++ Src/utils.c	20 Dec 2010 10:02:04 -0000
@@ -2272,7 +2272,7 @@ checkrmall(char *s)
 
 /**/
 mod_export ssize_t
-read_loop(int fd, void *buf, size_t len)
+read_loop(int fd, char *buf, size_t len)
 {
     ssize_t got = len;
 
@@ -2298,7 +2298,7 @@ read_loop(int fd, void *buf, size_t len)
 
 /**/
 mod_export ssize_t
-write_loop(int fd, const void *buf, size_t len)
+write_loop(int fd, const char *buf, size_t len)
 {
     ssize_t wrote = len;
 
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.126
diff -p -u -r1.126 zle_main.c
--- Src/Zle/zle_main.c	20 Sep 2010 09:27:46 -0000	1.126
+++ Src/Zle/zle_main.c	20 Dec 2010 10:02:04 -0000
@@ -1132,7 +1132,7 @@ zleread(char **lp, char **rp, int flags,
 	pptbuf = unmetafy(promptexpand(lp ? *lp : NULL, 0, NULL, NULL,
 				       &pmpt_attr),
 			  &pptlen);
-	write_loop(2, (WRITE_ARG_2_T)pptbuf, pptlen);
+	write_loop(2, pptbuf, pptlen);
 	free(pptbuf);
 	return shingetline();
     }

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-20 10:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-20  6:00 PATCH: Errors compiling on HP-UX with HP's compiler Paul Ackersviller
2010-12-20  8:57 ` Vincent Lefevre
2010-12-20 10:07 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).