unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* importing getloadavg from gnulib
@ 2011-02-08  7:22 Paul Eggert
  2011-02-08  8:31 ` Dan Nicolaescu
  2011-02-08  9:02 ` Eli Zaretskii
  0 siblings, 2 replies; 14+ messages in thread
From: Paul Eggert @ 2011-02-08  7:22 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 4064 bytes --]

Attached is a patch to have Emacs import getloadavg from gnulib
instead of maintining its own special version.  This has some
porting and bugfix advantages (see ChangeLog entry below).  I have
not installed this yet, to give the Windows porters a heads-up.

After the ChangeLog entry below I have listed the most important
changes in the patch.  (Most of the full patch file is bzr overhead
or autogenerated files.)  If Windows ports are compiling getloadavg.c,
they'll need to do so in the lib directory, not the src directory.
I don't expect any of the new symbols in config.in need to be
configured on Windows.

2011-02-08  Paul Eggert  <eggert@cs.ucla.edu>

	Import getloadavg module from gnulib.
	* .bzrignore: Add lib/stdlib.h.
	* Makefile.in (GNULIB_MODULES): Add getloadavg.
	* admin/notes/copyright: Remove src/getloadavg.c as a special case.
	* configure.in (LIBS_SYSTEM): Omit -lkstat on sol2*; gnulib does this.
	(AC_CONFIG_LIBOBJ_DIR, AC_FUNC_GETLOADAVG, GETLOADAVG_FILES):
	Remove; gnulib does this now.
	* lib/getloadavg.c: Rename from src/getloadavg.c, and sync
	from gnulib.  This adds support for several other systems, such
	as Tru64 4.0D, QNX, AIX perfstat, etc.  It also fixes a potential
	buffer overrun on Linux hosts under very high load, and on hosts
	that maintain a channel to the load average file it makes sure
	the file descriptor is close-on-exec (on hosts that support this)
	and is not stdin, stdout, or stderr.
	* lib/stdlib.in.h, m4/getloadavg.m4, m4/stdlib_h.m4: New files,
	from gnulib.
	* aclocal.m4, configure, lib/Makefile.in, lib/gnulib.mk, m4/gl-comp.m4:
	* src/config.in: Regenerate.
	* src/deps.mk (getloadavg.o): Remove; gnulib now does this.
	* src/lisp.h (getloadavg) [!defined HAVE_GETLOADAVG]: Remove; gnulib
	now does this.
	* src/s/freebsd.h (HAVE_GETLOADAVG): Remove; gnulib now does this.
	* src/s/netbsd.h (HAVE_GETLOADAVG): Likewise.
	* src/config.in: Regenerate.

=== modified file 'configure.in'
--- configure.in	2011-02-05 22:30:14 +0000
+++ configure.in	2011-02-08 07:05:03 +0000
@@ -984,7 +984,7 @@
 
   hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
 
-  sol2*) LIBS_SYSTEM="-lsocket -lnsl -lkstat" ;;
+  sol2*) LIBS_SYSTEM="-lsocket -lnsl" ;;
 
   ## Motif needs -lgen.
   unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;;
@@ -1000,9 +1000,6 @@
   CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
 fi
 
-dnl For AC_FUNC_GETLOADAVG, at least:
-AC_CONFIG_LIBOBJ_DIR(src)
-
 dnl Do this early because it can frob feature test macros for Unix-98 &c.
 AC_SYS_LARGEFILE
 
@@ -2665,8 +2662,6 @@
 
 AC_CHECK_HEADERS(sys/un.h)
 
-AC_FUNC_GETLOADAVG
-
 AC_FUNC_FSEEKO
 
 AC_FUNC_GETPGRP
@@ -3115,7 +3110,6 @@
 S_FILE="\$(srcdir)/${opsysfile}"
 AC_SUBST(M_FILE)
 AC_SUBST(S_FILE)
-AC_SUBST(GETLOADAVG_LIBS)
 AC_SUBST(ns_appdir)
 AC_SUBST(ns_appbindir)
 AC_SUBST(ns_appresdir)

=== renamed file 'src/getloadavg.c' => 'lib/getloadavg.c'
[diffs omitted here; see full patch]
=== added file 'lib/stdlib.in.h'
[contents omitted here; see full patch.  stdlib.h declares getloadavg.
 On Windows the declaration may not be needed, and if so, Windows
 should not need to worry about this file.]
=== modified file 'src/deps.mk'
--- src/deps.mk	2011-02-04 12:01:34 +0000
+++ src/deps.mk	2011-02-08 07:05:03 +0000
@@ -115,7 +115,6 @@
 ftfont.o: ftfont.c dispextern.h frame.h character.h charset.h composite.h \
    font.h lisp.h $(config_h) blockinput.h atimer.h systime.h coding.h \
    fontset.h ccl.h ftfont.h globals.h
-getloadavg.o: getloadavg.c $(config_h)
 gnutls.o: gnutls.c gnutls.h process.h ../lib/unistd.h \
    lisp.h globals.h $(config_h)
 gtkutil.o: gtkutil.c gtkutil.h xterm.h lisp.h frame.h lisp.h $(config_h) \

=== modified file 'src/lisp.h'
--- src/lisp.h	2011-02-07 02:18:35 +0000
+++ src/lisp.h	2011-02-08 07:05:03 +0000
@@ -3407,11 +3407,6 @@
 EXFUN (Fx_load_color_file, 1);
 extern void syms_of_xfaces (void);
 
-#ifndef HAVE_GETLOADAVG
-/* Defined in getloadavg.c */
-extern int getloadavg (double *, int);
-#endif
-
 #ifdef HAVE_X_WINDOWS
 /* Defined in xfns.c */
 extern void syms_of_xfns (void);

[-- Attachment #2: getloadavg-patch.txt.gz --]
[-- Type: application/x-gzip, Size: 52100 bytes --]

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

* Re: importing getloadavg from gnulib
  2011-02-08  7:22 importing getloadavg from gnulib Paul Eggert
@ 2011-02-08  8:31 ` Dan Nicolaescu
  2011-02-08  9:01   ` Andreas Schwab
  2011-02-08  9:02 ` Eli Zaretskii
  1 sibling, 1 reply; 14+ messages in thread
From: Dan Nicolaescu @ 2011-02-08  8:31 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

Paul Eggert <eggert@cs.ucla.edu> writes:

> Attached is a patch to have Emacs import getloadavg from gnulib
> instead of maintining its own special version.  This has some
> porting and bugfix advantages (see ChangeLog entry below).  I have
> not installed this yet, to give the Windows porters a heads-up.
>
> After the ChangeLog entry below I have listed the most important
> changes in the patch.  (Most of the full patch file is bzr overhead
> or autogenerated files.)  If Windows ports are compiling getloadavg.c,
> they'll need to do so in the lib directory, not the src directory.
> I don't expect any of the new symbols in config.in need to be
> configured on Windows.

Thanks for doing this! 
Can you please remove the
LOAD_AVE_CVT/LOAD_AVE_TYPE/LDAV_SYMBOL/FSCALE 
definitions in src/[sm]/* that are not needed anymore?



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

* Re: importing getloadavg from gnulib
  2011-02-08  8:31 ` Dan Nicolaescu
@ 2011-02-08  9:01   ` Andreas Schwab
  2011-02-10  7:54     ` Paul Eggert
  0 siblings, 1 reply; 14+ messages in thread
From: Andreas Schwab @ 2011-02-08  9:01 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: Paul Eggert, emacs-devel

Dan Nicolaescu <dann@gnu.org> writes:

> Can you please remove the
> LOAD_AVE_CVT/LOAD_AVE_TYPE/LDAV_SYMBOL/FSCALE 
> definitions in src/[sm]/* that are not needed anymore?

Also from admin/CPP-DEFINES.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



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

* Re: importing getloadavg from gnulib
  2011-02-08  7:22 importing getloadavg from gnulib Paul Eggert
  2011-02-08  8:31 ` Dan Nicolaescu
@ 2011-02-08  9:02 ` Eli Zaretskii
  2011-02-08  9:28   ` Paul Eggert
  1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2011-02-08  9:02 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

> Date: Mon, 07 Feb 2011 23:22:07 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> 
> Attached is a patch to have Emacs import getloadavg from gnulib
> instead of maintining its own special version.  This has some
> porting and bugfix advantages (see ChangeLog entry below).  I have
> not installed this yet, to give the Windows porters a heads-up.

Thanks.  I cannot try the Windows build where I'm typing this, so the
below is based only on reading the diffs.  Please take it with a grain
of salt, and apologies if I made wrong conclusions as result.

> After the ChangeLog entry below I have listed the most important
> changes in the patch.  (Most of the full patch file is bzr overhead
> or autogenerated files.)  If Windows ports are compiling getloadavg.c,
> they'll need to do so in the lib directory, not the src directory.
> I don't expect any of the new symbols in config.in need to be
> configured on Windows.

The Windows build has its own implementation of getloadavg, see
w32.c.  So it does not compile src/getloadavg.c, and therefore does
not need the new gnulib stuff.  However, this change in src/lisp.h:

> -#ifndef HAVE_GETLOADAVG
> -/* Defined in getloadavg.c */
> -extern int getloadavg (double *, int);
> -#endif

will cause the prototype of getloadavg to become unavailable in the
Windows build, because the Windows stdlib.h obviously does not declare
it.  So I think we should leave the declaration in place for the
Windows build at the least.

The MS-DOS build does compile src/getloadavg.c, but the code for
MS-DOS there is a trivial stub (and remains as such in the new
version).  So I can either change the MS-DOS build to use the new
version in lib/, or provide the same trivial stub in MS-DOS specific
source files, like Windows does.  What would you suggest?

One question unrelated to DOS/Windows: it looks like we are adding
stdlib.h from gnulib for getloadavg's sake, but we get gobs of
unrelated stuff as a side effect.  For example, the
*_CANONICALIZE_FILE_NAME macros, the *_UNSETENV macros, etc. -- these
aren't used anywhere in getloadavg.c, it seems, they are there just
because gnulib's stdlib.h needs them.  This seems rather inelegant.
Isn't there a cleaner way of getting just getloadavg without all that
surplus?



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

* Re: importing getloadavg from gnulib
  2011-02-08  9:02 ` Eli Zaretskii
@ 2011-02-08  9:28   ` Paul Eggert
  2011-02-08 10:28     ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Paul Eggert @ 2011-02-08  9:28 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 02/08/2011 01:02 AM, Eli Zaretskii wrote:

> However, this change in src/lisp.h:
> 
>> -#ifndef HAVE_GETLOADAVG
>> -/* Defined in getloadavg.c */
>> -extern int getloadavg (double *, int);
>> -#endif
> 
> will cause the prototype of getloadavg to become unavailable in the
> Windows build, because the Windows stdlib.h obviously does not declare
> it.  So I think we should leave the declaration in place for the
> Windows build at the least.

Since only Windows needs it now, how about if we move it
to src/s/ms-w32.h?  That way, it's clearly localized to the
Windows port.

> I can either change the MS-DOS build to use the new
> version in lib/, or provide the same trivial stub in MS-DOS specific
> source files, like Windows does.  What would you suggest?

I'd do whatever's easier for MS-DOS and Windows, since the
mainstream source is unaffected by this decision.

> the *_CANONICALIZE_FILE_NAME macros, the *_UNSETENV macros, etc. -- these
> aren't used anywhere in getloadavg.c, it seems, they are there just
> because gnulib's stdlib.h needs them.

Yes, they're there only because stdlib.h declares them (on GNU
platforms), and gnulib's stdlib.h substitute has placeholders for them
in case you also want to use the modules canonicalize, unsetenv, etc.
I expect it's not worth removing those placeholders, at least partly
because Emacs can use some of them in the future.



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

* Re: importing getloadavg from gnulib
  2011-02-08  9:28   ` Paul Eggert
@ 2011-02-08 10:28     ` Eli Zaretskii
  0 siblings, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2011-02-08 10:28 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

> Date: Tue, 08 Feb 2011 01:28:34 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: emacs-devel@gnu.org
> 
> On 02/08/2011 01:02 AM, Eli Zaretskii wrote:
> 
> > However, this change in src/lisp.h:
> > 
> >> -#ifndef HAVE_GETLOADAVG
> >> -/* Defined in getloadavg.c */
> >> -extern int getloadavg (double *, int);
> >> -#endif
> > 
> > will cause the prototype of getloadavg to become unavailable in the
> > Windows build, because the Windows stdlib.h obviously does not declare
> > it.  So I think we should leave the declaration in place for the
> > Windows build at the least.
> 
> Since only Windows needs it now, how about if we move it
> to src/s/ms-w32.h?  That way, it's clearly localized to the
> Windows port.

That'd be fine.



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

* Re: importing getloadavg from gnulib
  2011-02-08  9:01   ` Andreas Schwab
@ 2011-02-10  7:54     ` Paul Eggert
  2011-02-15  6:49       ` Paul Eggert
  0 siblings, 1 reply; 14+ messages in thread
From: Paul Eggert @ 2011-02-10  7:54 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Dan Nicolaescu, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 360 bytes --]

On 02/08/2011 01:01 AM, Andreas Schwab wrote:
> Dan Nicolaescu <dann@gnu.org> writes:
> 
>> > Can you please remove the
>> > LOAD_AVE_CVT/LOAD_AVE_TYPE/LDAV_SYMBOL/FSCALE 
>> > definitions in src/[sm]/* that are not needed anymore?
> Also from admin/CPP-DEFINES.

That's easily enough done, as in the attached
(cumulative) patch.  It also removes KERNEL_FILE.

[-- Attachment #2: getloadavg1-patch.txt.gz --]
[-- Type: application/x-gzip, Size: 59866 bytes --]

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

* Re: importing getloadavg from gnulib
  2011-02-10  7:54     ` Paul Eggert
@ 2011-02-15  6:49       ` Paul Eggert
  2011-02-15 18:13         ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Paul Eggert @ 2011-02-15  6:49 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 471 bytes --]

On 02/09/2011 11:54 PM, Paul Eggert wrote:

> That's easily enough done, as in the attached
> (cumulative) patch.  It also removes KERNEL_FILE.

I've tuned getloadavg in gnulib so that 'configure' should
run faster for Emacs.  This updates my proposed patch for
getloadavg, and the updated patch is attached.  I don't
expect this tuning to affect the Windows version but thought
I'd give a heads-up.  I haven't applied this to the trunk
yet as I plan to do more testing.

[-- Attachment #2: getloadavg2-patch.txt.gz --]
[-- Type: application/x-gzip, Size: 63594 bytes --]

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

* Re: importing getloadavg from gnulib
  2011-02-15  6:49       ` Paul Eggert
@ 2011-02-15 18:13         ` Eli Zaretskii
  2011-02-15 18:55           ` Paul Eggert
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2011-02-15 18:13 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

> Date: Mon, 14 Feb 2011 22:49:12 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> 
> I've tuned getloadavg in gnulib so that 'configure' should
> run faster for Emacs.  This updates my proposed patch for
> getloadavg, and the updated patch is attached.  I don't
> expect this tuning to affect the Windows version but thought
> I'd give a heads-up.

It shouldn't, but I think we agreed to move the prototype of
getloadavg from lisp.h to src/s/ms-w32.h.



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

* Re: importing getloadavg from gnulib
  2011-02-15 18:13         ` Eli Zaretskii
@ 2011-02-15 18:55           ` Paul Eggert
  2011-02-15 19:21             ` Eli Zaretskii
  2011-02-16 18:50             ` Eli Zaretskii
  0 siblings, 2 replies; 14+ messages in thread
From: Paul Eggert @ 2011-02-15 18:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 02/15/2011 10:13 AM, Eli Zaretskii wrote:
> I think we agreed to move the prototype of
> getloadavg from lisp.h to src/s/ms-w32.h.

Yes, that's right.  I've been assuming that you'd
make any changes specific to the Windows port.  This includes  any
makefile changes (which are needed here, I expect) and the change
to src/s/ms-w32.h.



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

* Re: importing getloadavg from gnulib
  2011-02-15 18:55           ` Paul Eggert
@ 2011-02-15 19:21             ` Eli Zaretskii
  2011-02-15 20:41               ` Paul Eggert
  2011-02-16 18:50             ` Eli Zaretskii
  1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2011-02-15 19:21 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

> Date: Tue, 15 Feb 2011 10:55:34 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: emacs-devel@gnu.org
> 
> On 02/15/2011 10:13 AM, Eli Zaretskii wrote:
> > I think we agreed to move the prototype of
> > getloadavg from lisp.h to src/s/ms-w32.h.
> 
> Yes, that's right.  I've been assuming that you'd
> make any changes specific to the Windows port.

I don't mind, but I need a heads-up.

> This includes any makefile changes (which are needed here, I expect)

Which makefile changes are needed?  I'm not aware of any (given that
getloadavg.c is not compiled into the Windows build).



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

* Re: importing getloadavg from gnulib
  2011-02-15 19:21             ` Eli Zaretskii
@ 2011-02-15 20:41               ` Paul Eggert
  2011-02-16  0:38                 ` Paul Eggert
  0 siblings, 1 reply; 14+ messages in thread
From: Paul Eggert @ 2011-02-15 20:41 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 02/15/2011 11:21 AM, Eli Zaretskii wrote:
>> This includes any makefile changes (which are needed here, I expect)
> Which makefile changes are needed?

Apparently I was wrong, and no makefile changes
are needed.  Sorry about the noise.



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

* Re: importing getloadavg from gnulib
  2011-02-15 20:41               ` Paul Eggert
@ 2011-02-16  0:38                 ` Paul Eggert
  0 siblings, 0 replies; 14+ messages in thread
From: Paul Eggert @ 2011-02-16  0:38 UTC (permalink / raw)
  To: emacs-devel

After a bit more testing, I've committed the getloadavg change
to the Emacs trunk, as revision 103286.  It's almost the same
as what's been circulated, with some minor changes to getloadavg
so that it sets errno appropriately when returning -1.



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

* Re: importing getloadavg from gnulib
  2011-02-15 18:55           ` Paul Eggert
  2011-02-15 19:21             ` Eli Zaretskii
@ 2011-02-16 18:50             ` Eli Zaretskii
  1 sibling, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2011-02-16 18:50 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

> Date: Tue, 15 Feb 2011 10:55:34 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: emacs-devel@gnu.org
> 
> On 02/15/2011 10:13 AM, Eli Zaretskii wrote:
> > I think we agreed to move the prototype of
> > getloadavg from lisp.h to src/s/ms-w32.h.
> 
> Yes, that's right.  I've been assuming that you'd
> make any changes specific to the Windows port.  This includes  any
> makefile changes (which are needed here, I expect) and the change
> to src/s/ms-w32.h.

Done.



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

end of thread, other threads:[~2011-02-16 18:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-08  7:22 importing getloadavg from gnulib Paul Eggert
2011-02-08  8:31 ` Dan Nicolaescu
2011-02-08  9:01   ` Andreas Schwab
2011-02-10  7:54     ` Paul Eggert
2011-02-15  6:49       ` Paul Eggert
2011-02-15 18:13         ` Eli Zaretskii
2011-02-15 18:55           ` Paul Eggert
2011-02-15 19:21             ` Eli Zaretskii
2011-02-15 20:41               ` Paul Eggert
2011-02-16  0:38                 ` Paul Eggert
2011-02-16 18:50             ` Eli Zaretskii
2011-02-08  9:02 ` Eli Zaretskii
2011-02-08  9:28   ` Paul Eggert
2011-02-08 10:28     ` Eli Zaretskii

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

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).