From norton@REDACTED Wed Oct 1 09:40:25 2008 From: norton@REDACTED (Joseph Wayne Norton) Date: Wed, 01 Oct 2008 16:40:25 +0900 Subject: [erlang-patches] supervisor patch for parameterized modules Message-ID: The supervisor application does not support children that are implemented by a parameterized module. The following change permits a tuple for a child spec. Is this behavior by design (possibly for code reloading purposes)? -- norton@REDACTED -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: otp_src_R12B-4-supervisor.txt URL: From norton@REDACTED Wed Oct 1 09:49:58 2008 From: norton@REDACTED (Joseph Wayne Norton) Date: Wed, 01 Oct 2008 16:49:58 +0900 Subject: [erlang-patches] R12B-? compiler patch for parameterized modules Message-ID: The undocumented behavior of parameterized modules has changed since R11B. A minor change to the compiler would permit usage of ":new" only if there does not exist a function having the same name and same arity. The current behavior checks for only the same name. Please consider this change to be included in a future release. -- norton@REDACTED -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: otp_src_R12B-4-pmod.txt URL: From richardc@REDACTED Wed Oct 1 12:26:42 2008 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 01 Oct 2008 12:26:42 +0200 Subject: [erlang-patches] R12B-? compiler patch for parameterized modules In-Reply-To: References: Message-ID: <48E35062.3060100@it.uu.se> Joseph Wayne Norton wrote: > > The undocumented behavior of parameterized modules has changed since > R11B. A minor change to the compiler would permit usage of ":new" only > if there does not exist a function having the same name and same arity. > The current behavior checks for only the same name. Please consider > this change to be included in a future release. The idea is that if the user has already specified one or more functions called new/_, it means he has taken the responsibility for that part of the interface, and should call 'instance/N' himself, from at least one of these new-functions. This makes it possible to have a set of exported new-functions that do not include new/N. With your patch, the compiler would always insert new/N if you omit it, unless you also add some new compiler flag to suppress this - and I find that a worse solution. A concrete example: with the current behaviour, you can have a module such as: -module(m,[Ref,X,Y]). -export([new/1, new/2, get/0]). new(X) -> new(X, 0). new(X, Y) -> instance(make_ref(),X,Y). get() -> {X, Y, Ref}. where 1) the module is actually abstracted over an extra variable that you don't see in the interface functions (there is no new/3), and 2) the order of the parameters to the new-functions is different from that of instance/N (though I can't think of an example of when that would be useful). /Richard From saleyn@REDACTED Wed Oct 1 13:43:40 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Wed, 01 Oct 2008 07:43:40 -0400 Subject: [erlang-patches] supervisor patch for parameterized modules In-Reply-To: References: Message-ID: <48E3626C.4040301@gmail.com> Actually there's a bug in the patch below as the guards are not applied properly. This will be treated as a valid function: {{new, X}, "abc", 1234} You need to break these into two separate matches because the ';' guard delimiter has precedence over ',': validFunc({M, F, A}) when is_atom(M), is_atom(F), is_list(A) -> true; validFunc({M, F, A}) when is_tuple(M), is_atom(element(1, M)) , is_atom(F), is_list(A) -> true; ... Joseph Wayne Norton wrote: > > The supervisor application does not support children that are > implemented by a parameterized module. The following change permits a > tuple for a child spec. Is this behavior by design (possibly for code > reloading purposes)? > > *** ./otp_src_R12B-4/lib/stdlib/src/supervisor.erl.orig 2007-06-11 21:52:46.000000000 +0900 --- ./otp_src_R12B-4/lib/stdlib/src/supervisor.erl 2007-09-19 17:57:17.000000000 +0900 @@ -781,7 +781,7 @@ validName(_Name) -> true. -validFunc({M, F, A}) when is_atom(M), +validFunc({M, F, A}) when is_atom(M); is_tuple(M), is_atom(F), is_list(A) -> true; validFunc(Func) -> throw({invalid_mfa, Func}). From norton@REDACTED Thu Oct 2 09:26:55 2008 From: norton@REDACTED (Joseph Wayne Norton) Date: Thu, 02 Oct 2008 16:26:55 +0900 Subject: [erlang-patches] R12B-? compiler patch for parameterized modules In-Reply-To: <48E35062.3060100@it.uu.se> References: <48E35062.3060100@it.uu.se> Message-ID: Richard - Thanks for your feedback/comments. I will keep the patch as an internal patch until R11B is no longer in use and after mechanically replacing :new with :instance. As an aside, what is the motivation for having both :new and :instance support? In hindsight, I would have just stuck with using :instance if I had known about it in the first place :). thanks, - Joe N. On Wed, 01 Oct 2008 19:26:42 +0900, Richard Carlsson wrote: > Joseph Wayne Norton wrote: >> >> The undocumented behavior of parameterized modules has changed since >> R11B. A minor change to the compiler would permit usage of ":new" only >> if there does not exist a function having the same name and same arity. >> The current behavior checks for only the same name. Please consider >> this change to be included in a future release. > > The idea is that if the user has already specified one or more functions > called new/_, it means he has taken the responsibility for that part of > the interface, and should call 'instance/N' himself, from at least one > of these new-functions. This makes it possible to have a set of exported > new-functions that do not include new/N. With your patch, the compiler > would always insert new/N if you omit it, unless you also add some > new compiler flag to suppress this - and I find that a worse solution. > > A concrete example: with the current behaviour, you can have a module > such as: > > -module(m,[Ref,X,Y]). > > -export([new/1, new/2, get/0]). > > new(X) -> new(X, 0). > > new(X, Y) -> instance(make_ref(),X,Y). > > get() -> {X, Y, Ref}. > > where 1) the module is actually abstracted over an extra variable that > you don't see in the interface functions (there is no new/3), and 2) the > order of the parameters to the new-functions is different from that of > instance/N (though I can't think of an example of when that would be > useful). > > /Richard -- norton@REDACTED From richardc@REDACTED Thu Oct 2 10:05:49 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 02 Oct 2008 10:05:49 +0200 Subject: [erlang-patches] R12B-? compiler patch for parameterized modules In-Reply-To: References: <48E35062.3060100@it.uu.se> Message-ID: <48E480DD.1060808@it.uu.se> Joseph Wayne Norton wrote: > As an aside, what is the motivation for having both :new and :instance > support? In hindsight, I would have just stuck with using :instance if > I had known about it in the first place :). It wasn't there in the first place - it was added along with the experimental module inheritance functionality, to provide more control over how instantiation is performed. http://www.erlang.se/euc/07/papers/1700Carlsson.pdf /Richard From richardc@REDACTED Thu Oct 2 10:09:52 2008 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 02 Oct 2008 10:09:52 +0200 Subject: [erlang-patches] supervisor patch for parameterized modules In-Reply-To: References: Message-ID: <48E481D0.3020908@it.uu.se> Joseph Wayne Norton wrote: > The supervisor application does not support children that are > implemented by a parameterized module. The following change permits a > tuple for a child spec. Is this behavior by design (possibly for code > reloading purposes)? There's a lot of old code that assumes that a module is an atom and nothing else. To fully support modules-as-a-datatype, there should be a new type test is_module(X), rather than temporarily inserting tests for tuple-ness (which have to be changed when module objects are no longer represented as tuples). /Richard From zl9d97p02@REDACTED Fri Oct 3 17:02:54 2008 From: zl9d97p02@REDACTED (Simon Cornish) Date: Fri, 3 Oct 2008 17:02:54 +0200 Subject: [erlang-patches] erl_interface bug on 64-bit platforms Message-ID: <17608-08016@sneakemail.com> Hi, There is a nasty type-casting bug in erl_interface that affects 64-bit platforms. An application calling ei_skip_term with a term containing a binary will get undefined results (specifically, a core dump under Solaris 10 x86). A similar bug exists in the implementation of ei_printterm Attached is a patch for both. Regards, Simon -------------- next part -------------- A non-text attachment was scrubbed... Name: r12-erl_interface.patch Type: application/octet-stream Size: 1573 bytes Desc: not available URL: From egil@REDACTED Fri Oct 3 17:25:36 2008 From: egil@REDACTED (=?UTF-8?B?QmrDtnJuLUVnaWwgRGFobGJlcmc=?=) Date: Fri, 03 Oct 2008 17:25:36 +0200 Subject: [erlang-patches] erl_interface bug on 64-bit platforms In-Reply-To: <17608-08016@sneakemail.com> References: <17608-08016@sneakemail.com> Message-ID: <48E63970.4000709@erix.ericsson.se> Hi Simon, Thank you for reporting this and your patch. I will look into the problem. Regards, Bj?rn-Egil Erlang/OTP Simon Cornish wrote: > Hi, > There is a nasty type-casting bug in erl_interface that affects 64-bit > platforms. > An application calling ei_skip_term with a term containing a binary > will get undefined results (specifically, a core dump under Solaris 10 > x86). A similar bug exists in the implementation of ei_printterm > Attached is a patch for both. > Regards, > Simon > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-patches mailing list > erlang-patches@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-patches From nem@REDACTED Mon Oct 6 16:19:20 2008 From: nem@REDACTED (Geoff Cant) Date: Mon, 06 Oct 2008 16:19:20 +0200 Subject: [erlang-patches] TXT record decoding bug in inet_dns Message-ID: Hi there, while sneakily using the private inet_res API to do interesting DNS queries, I discovered a long-standing bug in inet_dns. inet_dns incorrectly decodes the RData for TXT records as RData instead of [Length | Text] = RData, Text. (The RData for TXT records is encoded as <>). Attached is a patch against R12B-4 to correct this bug. It should apply with patch -p1 from the OTP sources root. -------------- next part -------------- A non-text attachment was scrubbed... Name: dns_txt_record_fix.diff Type: text/x-patch Size: 663 bytes Desc: not available URL: -------------- next part -------------- The second patch fixes the encoding of TXT records in the same way. -------------- next part -------------- A non-text attachment was scrubbed... Name: dns_txt_record_fix2.diff Type: text/x-patch Size: 668 bytes Desc: not available URL: -------------- next part -------------- On a related note, I've found the functionality in inet_res to be particularly useful and would like to know if the OTP team would consider exposing and this functionality. This could be done as a new 'dns' modules for queries, resolution, encoding and decoding or perhaps just exporting and documenting some of these private inet_res, inet_dns functions. Ideally I would like to be able to do: dns:lookup(Name, Type) -> {error, Error} | {ok, RR}. dns:lookup(Server, Name, Type) dns:lookup(Server, Name, Type, Timeout) For at least the SOA, NS, TXT, A, CName, PTR, SRV and MX resource record types. I'd be happy to write patches or a new dns module if the OTP team would look favourably on including it in OTP. Cheers, -- Geoff Cant From geoff.cant@REDACTED Tue Oct 7 14:28:06 2008 From: geoff.cant@REDACTED (Geoff Cant) Date: Tue, 07 Oct 2008 14:28:06 +0200 Subject: [erlang-patches] [erlang-bugs] TXT record decoding bug in inet_dns In-Reply-To: (Matthew Dempsky's message of "Mon, 6 Oct 2008 08:26:07 -0700") References: Message-ID: "Matthew Dempsky" writes: > 2008/10/6 Geoff Cant : >> inet_dns incorrectly decodes the RData for TXT records as RData instead >> of [Length | Text] = RData, Text. (The RData for TXT records is encoded >> as <>). > > RDATA for TXT records allows more than one character string. Good point - in which case txt records should decode to a list of strings. Updated patch attached (encoding and decoding) against R12B-4 (supercedes previous patches). -------------- next part -------------- A non-text attachment was scrubbed... Name: dns_txt_record_fix3.diff Type: text/x-patch Size: 1445 bytes Desc: not available URL: -------------- next part -------------- Cheers, -- Geoff Cant From saleyn@REDACTED Fri Oct 10 15:42:19 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 10 Oct 2008 09:42:19 -0400 Subject: [erlang-patches] jinterface bug Message-ID: <48EF5BBB.5080207@gmail.com> While working with otp.net I encountered a fairly serious bug that has its origin in jinterface. The later doesn't detect remote node disconnects. Attached patch addresses the issue. Serge -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: AbstractConnection.java.patch URL: From saleyn@REDACTED Fri Oct 10 16:04:01 2008 From: saleyn@REDACTED (Serge Aleynikov) Date: Fri, 10 Oct 2008 10:04:01 -0400 Subject: [erlang-patches] code_server & ERL_LIBS bug Message-ID: <48EF60D1.1030704@gmail.com> There's an error in code server that causes erl & erlc to hang at startup if ERL_LIBS environment variable is set to an empty string or a string containing non-existing directories. Here's how to reproduce it: $ export ERL_LIBS= $ erl or $ export ERL_LIBS="/a/b/c" $ erl Attached patch corrects the problem. Regards, Serge -------------- next part -------------- A non-text attachment was scrubbed... Name: code_server.erl.patch Type: application/octet-stream Size: 1157 bytes Desc: not available URL: From oscar@REDACTED Fri Oct 10 23:32:02 2008 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Fri, 10 Oct 2008 14:32:02 -0700 Subject: [erlang-patches] cover:compile_beam/1 (tools-2.6.2) crashes if BeamFile cannot be found Message-ID: <48EFC9D2.9070405@erlang-consulting.com> compile_beam/1 crashes in do_compile_beam/2 if BeamFile doesn't exist Since the docs don't have any proper return value for this case I don't really know what to return, but here's a simple patch anyhow. I think it should also deal with any other issue with reading the file, such as access permissions etc. Best regards -- Oscar Hellstr?m, oscar@REDACTED Phone: +44 (0)798 45 44 773 Mobile: +44 (0)207 65 50 337 Web: http://www.erlang-consulting.com -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: otp_src_R12B.lib.cover.patch URL: From akitada@REDACTED Sun Oct 12 03:22:29 2008 From: akitada@REDACTED (Akira Kitada) Date: Sun, 12 Oct 2008 10:22:29 +0900 Subject: [erlang-patches] Make Erlang compile on FreeBSD 6.3 Message-ID: <90bb445a0810111822s1651038fj937d1ff1632780f@mail.gmail.com> To build R12B-4 on FreeBSD 6.3, I had to apply the following patches. Your can reproduce this problem by simply invoking "./configure --enable-threads --enable-dynamic-ssl-lib && gmake" (If you run configure without arguments, the build will fail, but that's another story) (1) gethostbyname_r argument [Problem] gcc -g -O2 -DEI_64BIT -fPIC -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -fno-strict-aliasing -I. -I../include -Iconnect -Iencode -Idecode -Imisc -Iepmd -Iregistry -Ix86_64-unknown-freebsd6.3 -D_REENTRANT -D_THREAD_SAFE -DPOSIX_THREADS -c connect/ei_resolve.c -o /home/akira/src/otp_src_R12B-4/lib/erl_interface/obj.mt/x86_64-unknown-freebsd6.3/ei_resolve.o connect/ei_resolve.c: In function `ei_gethostbyname_r': connect/ei_resolve.c:629: warning: passing arg 5 of `gethostbyname_r' from incompatible pointer type connect/ei_resolve.c:629: error: too few arguments to function `gethostbyname_r' connect/ei_resolve.c:629: warning: return makes pointer from integer without a cast [Fix] --- lib/erl_interface/src/connect/ei_resolve.c.orig 2008-10-12 08:41:50.000000000 +0900 +++ lib/erl_interface/src/connect/ei_resolve.c 2008-10-12 08:42:23.000000000 +0900 @@ -619,7 +619,7 @@ #ifndef HAVE_GETHOSTBYNAME_R return my_gethostbyname_r(name,hostp,buffer,buflen,h_errnop); #else -#ifdef __GLIBC__ +#if (defined(__GLIBC__) || (__FreeBSD_version >= 602000)) struct hostent *result; gethostbyname_r(name, hostp, buffer, buflen, &result, h_errnop); (2) Type of get_extended_mem [Problem] gcc -c -o ../priv/obj/x86_64-unknown-freebsd6.3/memsup.o -g -O2 -I/home/akira/src/otp_src_R12B-4/erts/x86_64-unknown-freebsd6.3 -DHAVE_CONFIG_H memsup.c memsup.c: In function `get_extended_mem': memsup.c:456: error: void value not ignored as it ought to be [Fix] http://www.freebsd.org/cgi/cvsweb.cgi/ports/lang/erlang/files/patch-lib_os__mon_c__src_memsup.c From alexander.uvarov@REDACTED Sun Oct 12 19:01:58 2008 From: alexander.uvarov@REDACTED (Alexander) Date: Sun, 12 Oct 2008 23:01:58 +0600 Subject: [erlang-patches] MD4 and DES in ECB mode for crypto module Message-ID: <200810122301.58974.alexander.uvarov@gmail.com> Hi there, this small patch (see attachment) adds missing md4 and DES in ECB mode encryption routine. It's useful to have lightweight hash function, also such methods are utilized by some protocols (e.g.: mschap2). If it makes sense, please apply. New crypto methods: md4, md4_init, md4_update, md4_final, des_ecb_encrypt, des_ecb_decrypt Cheers. -------------- next part -------------- A non-text attachment was scrubbed... Name: crypto_md4_des_ecb.diff Type: text/x-patch Size: 5269 bytes Desc: not available URL: From bgustavsson@REDACTED Mon Oct 13 12:25:17 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Mon, 13 Oct 2008 12:25:17 +0200 Subject: [erlang-patches] code_server & ERL_LIBS bug In-Reply-To: <48EF60D1.1030704@gmail.com> References: <48EF60D1.1030704@gmail.com> Message-ID: <6672d0160810130325h2cf5a74cr7e9536a1453d86ec@mail.gmail.com> 2008/10/10 Serge Aleynikov > There's an error in code server that causes erl & erlc to hang at startup > if ERL_LIBS environment variable is set to an empty string or a string > containing non-existing directories. > > Thanks! It will be corrected in R12B-5. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Fri Oct 17 10:54:00 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 17 Oct 2008 10:54:00 +0200 Subject: [erlang-patches] [erlang-bugs] leap-second-enabled FreeBSD doesn't work right with R12B4 erts/emulator/beam/erl_time_sup.c; correction patch included In-Reply-To: <20080914014111.GA7026@k2r.org> References: <20080914014111.GA7026@k2r.org> Message-ID: <6672d0160810170154h4f74cc8do7a79828363112729@mail.gmail.com> On Sun, Sep 14, 2008 at 3:41 AM, Kenji Rikitake wrote: > A patch to correct erlang:universaltime_to_localtime/1 > for FreeBSD running leap-second-enabled timezone > by Kenji Rikitake > 14-SEP-2008 > > * Summary > > This patch fixes the time calculation problem of > FreeBSD 6.x and 7.x, which has the internal leap-second > correction enabled. > This patch is tested with Erlang/OTP R12B-4 source distribution. > We will probably add the patch to R12B-5 with slight modifications. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Fri Oct 17 11:05:42 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 17 Oct 2008 11:05:42 +0200 Subject: [erlang-patches] supervisor patch for parameterized modules In-Reply-To: References: Message-ID: <6672d0160810170205n39a7272aw34551682656339e1@mail.gmail.com> 2008/10/1 Joseph Wayne Norton > > The supervisor application does not support children that are implemented > by a parameterized module. The following change permits a tuple for a child > spec. Is this behavior by design (possibly for code reloading purposes)? > Thanks! We will fix this in a future release (not R12B-5), as well as other updates to parameterized modules. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Fri Oct 17 11:49:12 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 17 Oct 2008 11:49:12 +0200 Subject: [erlang-patches] [PATCH] 64-bit solaris builds In-Reply-To: <48B72DC8.4030507@alertlogic.net> References: <48B72DC8.4030507@alertlogic.net> Message-ID: <6672d0160810170249i1e331d1u2c8cd40db3d17297@mail.gmail.com> On Fri, Aug 29, 2008 at 12:59 AM, Paul Fisher wrote: > This patch allows 64-bit builds when the target system supports both > 32-bit and 64-bit in the same system environment. Specifically, this > works on Solaris 10/Opensolaris, and adjusts the --enable-darwin-64-bit > configure flag to be simply --enable-64bit so that it can be used for > the same purpose on both darwin and solaris (building 64-bit target > environment) without having to introduce another system specific > configure flag. > We will address this issue in a future release (not R12B-5) by making sure that CFLAGS will be properly propagated by all Makefiles. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Fri Oct 17 11:56:09 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Fri, 17 Oct 2008 11:56:09 +0200 Subject: [erlang-patches] shared library avoidance code harmful on certain architectures In-Reply-To: <20080926124031.GC19155@cs.uni-bonn.de> References: <20080926124031.GC19155@cs.uni-bonn.de> Message-ID: <6672d0160810170256n79dfb45eva32301210bb6dd0@mail.gmail.com> On Fri, Sep 26, 2008 at 2:40 PM, Ignatios Souvatzis wrote: > Hi, > > erlang 12 fails to build on NetBSD/amd64. I was told to test the > patches below. > > Basically - use of -lfoo will do the right thing on all (sane) systems, > while the complicated stuff ended up using libfoo.a, which happened to > work on NetBSD/i386, but fails on NetBSD/amd64 due to the created text > relocations. > In a future release, we will change the default to link dynamically, with an option to link statically. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From bgustavsson@REDACTED Tue Oct 21 15:53:05 2008 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Tue, 21 Oct 2008 15:53:05 +0200 Subject: [erlang-patches] Patch for user_drv.erl In-Reply-To: <3dbc6d1c0808260828w2c5e332dhff1e1ffc35d719c8@mail.gmail.com> References: <3dbc6d1c0808260828w2c5e332dhff1e1ffc35d719c8@mail.gmail.com> Message-ID: <6672d0160810210653r1016b456y98c8a58d17105844@mail.gmail.com> 2008/8/26 Robert Virding > This is a patch for user_drv.erl which allows the user to specify which > shell/program to start when starting a new job, both local and remote. The > patch includes a modified help text. It is completely backwards compatible. > > It has been tested in LFE with no problems. > Thanks! We will include the patch in R12B-5. /Bjorn > > _______________________________________________ > erlang-patches mailing list > erlang-patches@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-patches > -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From jean-sebastien.pedron@REDACTED Wed Oct 29 16:12:33 2008 From: jean-sebastien.pedron@REDACTED (=?UTF-8?B?SmVhbi1Tw6liYXN0aWVuIFDDqWRyb24=?=) Date: Wed, 29 Oct 2008 16:12:33 +0100 Subject: [erlang-patches] Producing dependencies Makefile for Erlang using erlc(1) Message-ID: <49087D61.4020104@dumbbell.fr> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, When using erlc(1) and standard Makefiles to compile Erlang source files, there's currently no way to track header dependencies. Thus, if a header is modified, a module that depends on it will be recompiled only if the dependency is explicitly indicated in the Makefile. This becomes problematic when the header is external (for instance, a header from another application, such as xmerl.hrl). Attached is a patch that adds support for producing dependencies Makefiles to erlc(1) and compiler(3). It was modeled after GCC. For example, let's take the following module: -module(mod1). -include("header1.hrl"). ... The command "erlc -M mod1.erl" will output: mod1.beam: mod1.erl header1.hrl The patch adds the following options to erlc(1) and compiler(3): -M generate a rule describing dependencies; output on stdout. -MF File rule(s) is(are) written to `File'. -MT Target change the name of the rule emitted. -MQ Target same as -MT but quote special characters for make(1). -MG consider missing headers as generated files and add the to the dependencies -MP add a phony target for each dependency. -MD same as -M -MT file.Pbeam They're the same as GCC. The following options are not supported: -MM ignore system headers -MMD same as -MD but ignore system headers I choose to keep the same names as GCC because I'm working on Erlang support in Automake and it wants to use these options. Regarding compiler(3), options could have a more Erlang-fashion name. The patch, against R12B-4, includes the documentation updates. But I don't know how to make it, so it's untested. Thanks, PS: I already sent an older patch to erlang-questions@ more than a year ago. The attached patch obsoletes it. - -- Jean-S?bastien P?dron http://www.dumbbell.fr/ PGP Key: http://www.dumbbell.fr/pgp/pubkey.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkkIfWAACgkQa+xGJsFYOlP9swCdGsB6Ydsa6yTz3dLijCeyFAGh NzgAoMAsrNe2oEan+1ItXO+IuRVuSNwU =GOml -----END PGP SIGNATURE----- -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: otp_src_R12B-4-makedep-d.patch URL: From oscar@REDACTED Wed Oct 29 16:30:53 2008 From: oscar@REDACTED (=?utf-8?Q?Oscar_Hellstr=C3=B6m?=) Date: Wed, 29 Oct 2008 15:30:53 +0000 (GMT) Subject: [erlang-patches] Producing dependencies Makefile for Erlang using erlc(1) In-Reply-To: <49087D61.4020104@dumbbell.fr> Message-ID: <9303310.26291225294253246.JavaMail.root@zimbra> Hi, How does this deal with header files included with -include_lib(). For our build purposes we use a small shellscript to generate dependencies, which also takes -include_lib directives into consideration. I must say that I really welcome this though :) Now we just support for pkg-config to be able to compile drivers without pain as well. Ofc, we have a erl-config script for this instead :/ ----- "Jean-S?bastien P?dron" wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hello, > > When using erlc(1) and standard Makefiles to compile Erlang source > files, there's currently no way to track header dependencies. Thus, if > a > header is modified, a module that depends on it will be recompiled > only > if the dependency is explicitly indicated in the Makefile. This > becomes > problematic when the header is external (for instance, a header from > another application, such as xmerl.hrl). > > Attached is a patch that adds support for producing dependencies > Makefiles to erlc(1) and compiler(3). It was modeled after GCC. > > For example, let's take the following module: > -module(mod1). > -include("header1.hrl"). > ... > > The command "erlc -M mod1.erl" will output: > mod1.beam: mod1.erl header1.hrl > > The patch adds the following options to erlc(1) and compiler(3): > > -M generate a rule describing dependencies; output on > stdout. > -MF File rule(s) is(are) written to `File'. > -MT Target change the name of the rule emitted. > -MQ Target same as -MT but quote special characters for make(1). > -MG consider missing headers as generated files and add > the > to the dependencies > -MP add a phony target for each dependency. > -MD same as -M -MT file.Pbeam > > They're the same as GCC. The following options are not supported: > > -MM ignore system headers > -MMD same as -MD but ignore system headers > > I choose to keep the same names as GCC because I'm working on Erlang > support in Automake and it wants to use these options. Regarding > compiler(3), options could have a more Erlang-fashion name. > > The patch, against R12B-4, includes the documentation updates. But I > don't know how to make it, so it's untested. > > Thanks, > > PS: I already sent an older patch to erlang-questions@ more than a > year > ago. The attached patch obsoletes it. > > - -- > Jean-S?bastien P?dron > http://www.dumbbell.fr/ > > PGP Key: http://www.dumbbell.fr/pgp/pubkey.asc > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (FreeBSD) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkkIfWAACgkQa+xGJsFYOlP9swCdGsB6Ydsa6yTz3dLijCeyFAGh > NzgAoMAsrNe2oEan+1ItXO+IuRVuSNwU > =GOml > -----END PGP SIGNATURE----- > > diff -Naur otp_src_R12B-4/erts/doc/src/erlc.xml > otp_src_R12B-4-makedep/erts/doc/src/erlc.xml > --- otp_src_R12B-4/erts/doc/src/erlc.xml 2008-02-05 14:37:24.000000000 > +0100 > +++ otp_src_R12B-4-makedep/erts/doc/src/erlc.xml 2008-10-29 > 15:50:58.000000000 +0100 > @@ -135,6 +135,50 @@ > for compiling native code, which needs to be compiled with > the same > run-time system that it should be run on.

> > + -M > + > +

Produces a Makefile rule to track headers dependencies. > The > + rule is sent to stdout. No object file is produced. > +

> +
> + -MF Makefile > + > +

Like the option above, except that > the > + Makefile is written to Makefile. No object > + file is produced. > +

> +
> + -MD > + > +

Same as .Pbeam]]>. > +

> +
> + -MT Target > + > +

In conjunction with or > + , change the name of the rule emitted > + to Target. > +

> +
> + -MQ Target > + > +

Like the option above, except that > + characters special to make(1) or quoted. > +

> +
> + -MP > + > +

In conjunction with or > + , add a phony target for each > dependency. > +

> +
> + -MG > + > +

In conjunction with or > + , consider missing headers as > generated > + files and add them to the dependencies. > +

> +
> -- > >

Signals that no more options will follow. > diff -Naur otp_src_R12B-4/erts/etc/common/erlc.c > otp_src_R12B-4-makedep/erts/etc/common/erlc.c > --- otp_src_R12B-4/erts/etc/common/erlc.c 2008-02-05 > 14:37:24.000000000 +0100 > +++ otp_src_R12B-4-makedep/erts/etc/common/erlc.c 2008-10-29 > 11:53:03.000000000 +0100 > @@ -255,6 +255,66 @@ > case 'I': > PUSH2("@i", process_opt(&argc, &argv, 0)); > break; > + case 'M': > + { > + char *buf, *key, *val; > + size_t buf_len, key_len, val_len; > + > + if (argv[1][2] == '\0') { /* -M */ > + buf = emalloc(4); > + buf[0] = '\''; > + buf[1] = argv[1][1]; > + buf[2] = '\''; > + buf[3] = '\0'; > + > + PUSH2("@option", buf); > + } else { > + switch(argv[1][2]) { > + case 'P': /* -MP */ > + case 'D': /* -MD */ > + case 'G': /* -MG */ > + buf = emalloc(5); > + buf[0] = '\''; > + buf[1] = argv[1][1]; > + buf[2] = argv[1][2]; > + buf[3] = '\''; > + buf[4] = '\0'; > + > + PUSH2("@option", buf); > + break; > + case 'T': /* -MT */ > + case 'Q': /* -MQ */ > + case 'F': /* -MF */ > + switch (argv[1][2]) { > + case 'T': > + key = "'MT'"; > + break; > + case 'Q': > + key = "'MQ'"; > + break; > + case 'F': > + key = "'MF'"; > + break; > + default: > + key = "'M?'"; > + break; > + } > + key_len = strlen(key); > + val = process_opt(&argc, &argv, 1); > + val_len = strlen(val); > + > + buf_len = 1 + key_len + 2 + val_len + 2 + 1; > + buf = emalloc(buf_len); > + snprintf(buf, buf_len, "{%s,\"%s\"}", key, val); > + > + PUSH2("@option", buf); > + break; > + default: > + goto error; > + } > + } > + } > + break; > case 'o': > PUSH2("@outdir", process_opt(&argc, &argv, 0)); > break; > @@ -557,6 +617,15 @@ > {"-hybrid", "compile using hybrid-heap emulator"}, > {"-help", "shows this help text"}, > {"-I path", "where to search for include files"}, > + {"-M", "generate a rule for make(1) describing the dependencies"}, > + {"-MF file", "write the dependencies to `file'"}, > + {"-MT target", "change the target of the rule emitted by dependency > " > + "generation"}, > + {"-MQ target", "same as -MT but quote characters special to > make(1)"}, > + {"-MG", "consider missing headers as generated files and add them to > " > + "the dependencies"}, > + {"-MP", "add a phony target for each dependency"}, > + {"-MD", "same as -M -MT file (with default `file')"}, > {"-o name", "name output directory or file"}, > {"-pa path", "add path to the front of Erlang's code path"}, > {"-pz path", "add path to the end of Erlang's code path"}, > diff -Naur otp_src_R12B-4/lib/compiler/doc/src/compile.xml > otp_src_R12B-4-makedep/lib/compiler/doc/src/compile.xml > --- otp_src_R12B-4/lib/compiler/doc/src/compile.xml 2008-10-29 > 15:29:03.000000000 +0100 > +++ otp_src_R12B-4-makedep/lib/compiler/doc/src/compile.xml 2008-10-29 > 15:50:26.000000000 +0100 > @@ -164,6 +164,55 @@ > for details.

>
> > + 'M' > + > +

Produces a Makefile rule to track headers > dependencies. The > + rule is sent to stdout. No object file is produced. > +

> +
> + > + {'MF',Makefile} > + > +

Like the 'M' option above, except that the > Makefile > + is written to Makefile. No object file is > produced. > +

> +
> + > + 'MD' > + > +

Same as ['M', {'MF', > .Pbeam]]>}]. > +

> +
> + > + {'MT',Target} > + > +

In conjunction with 'M' or 'MF', change > the > + name of the rule emitted to Target. > +

> +
> + > + {'MQ',Target} > + > +

Like the {'MT',Target} option above, except > that > + characters special to make(1) or quoted. > +

> +
> + > + 'MP' > + > +

In conjunction with 'M' or 'MF', add a > phony > + target for each dependency. > +

> +
> + > + 'MG' > + > +

In conjunction with 'M' or 'MF', > consider > + missing headers as generated files and add them to the > + dependencies. > +

> +
> + > 'P' > >

Produces a listing of the parsed code after > preprocessing > diff -Naur otp_src_R12B-4/lib/compiler/src/compile.erl > otp_src_R12B-4-makedep/lib/compiler/src/compile.erl > --- otp_src_R12B-4/lib/compiler/src/compile.erl 2008-04-07 > 15:57:56.000000000 +0200 > +++ otp_src_R12B-4-makedep/lib/compiler/src/compile.erl 2008-10-29 > 15:18:37.000000000 +0100 > @@ -151,6 +151,12 @@ > expand_opt(no_float_opt, Os) -> > %%Turn off the entire type optimization pass. > [no_topt|Os]; > +expand_opt('MD', Os) -> > + ['M', {'MF', default} | Os]; > +expand_opt({'MQ', T}, Os) -> > + Fun = fun($$) -> "$$"; (C) -> C end, > + T1 = lists:flatten(lists:map(Fun, T)), > + [{'MT', T1} | Os]; > expand_opt(O, Os) -> [O|Os]. > > %% format_error(ErrorDescriptor) -> string() > @@ -398,6 +404,8 @@ > %% file will be Ext. (Ext should not contain > %% a period.) No more passes will be run. > %% > +%% done End compilation at this point. > +%% > %% {done,Ext} End compilation at this point. Produce a > listing > %% as with {listing,Ext}, unless 'binary' is > %% specified, in which case the current > @@ -431,6 +439,8 @@ > [{listing,fun (St) -> src_listing(Ext, St) end}]; > select_passes([{listing,Ext}|_], _Opts) -> > [{listing,fun (St) -> listing(Ext, St) end}]; > +select_passes([done|_], _Opts) -> > + []; > select_passes([{done,Ext}|_], Opts) -> > select_passes([{unless,binary,{listing,Ext}}], Opts); > select_passes([{iff,Flag,Pass}|Ps], Opts) -> > @@ -513,6 +523,10 @@ > > standard_passes() -> > [?pass(transform_module), > + > + {iff,'M',?pass(makedep)}, > + {iff,'M',done}, > + > {iff,'dpp',{listing,"pp"}}, > ?pass(lint_module), > {iff,'P',{src_listing,"P"}}, > @@ -852,6 +866,120 @@ > errors=St#compile.errors ++ Es}} > end. > > +makedep(#compile{options = Opts} = St) -> > + Ifile = St#compile.ifile, > + Ofile = St#compile.ofile, > + % Get the target of the Makefile rule. > + Target = case proplists:get_value('MT', Opts) of > + undefined -> > + % The target is derived from the output filename: eventually > + % remove the current working directory to obtain a relative > + % path. > + Cwd = proplists:get_value(cwd, Opts), > + case lists:prefix(Cwd, Ofile) of > + true -> lists:nthtail(length(Cwd) + 1, Ofile); > + false -> Ofile > + end; > + T -> > + % The caller specified one with "-MT". > + T > + end, > + Target1 = Target ++ ":", > + % List the dependencies (includes) for this target. > + {Main_Target, Phony} = makedep_add_headers(Ifile, > St#compile.code, > + [], length(Target1), Target1, "", Opts), > + % Prepare the content of the Makefile. For instance: > + % hello.erl: hello.hrl common.hrl > + % > + % Or if phony targets are enabled: > + % hello.erl: hello.hrl common.hrl > + % > + % hello.hrl: > + % > + % common.hrl: > + Makefile = case lists:member('MP', Opts) of > + true -> Main_Target ++ Phony; > + false -> Main_Target > + end, > + % Write this Makefile to the selected output. > + case proplists:get_value('MF', Opts) of > + undefined -> > + % Output to stdout. > + io:format("~s~n", [Makefile]); > + O -> > + % Output to a regular file. > + Output = case O of > + default -> filename:basename(Ofile, ".beam") ++ ".Pbeam"; > + _ -> O > + end, > + case file:open(Output, write) of > + {ok, Io_Dev} -> > + io:fwrite(Io_Dev, "~s~n", [Makefile]), > + file:close(Io_Dev); > + {error, Reason} -> > + io:format("Couldn't open makefile `~s': ~p~n", > + [Output, Reason]) > + end > + end, > + {ok, St}. > + > +makedep_add_headers(Ifile, [{attribute, _, file, {File, _}} | Rest], > + Included, Line_Len, Main_Target, Phony, Opts) -> > + {Included1, Line_Len1, Main_Target1, Phony1} = > makedep_add_header( > + Ifile, Included, Line_Len, Main_Target, Phony, File), > + makedep_add_headers(Ifile, Rest, Included1, Line_Len1, > + Main_Target1, Phony1, Opts); > +makedep_add_headers(Ifile, [{error, {_, epp, {include, file, File}}} > | Rest], > + Included, Line_Len, Main_Target, Phony, Opts) -> > + % The header doesn't exist, do we add it? > + case lists:member('MG', Opts) of > + true -> > + {Included1, Line_Len1, Main_Target1, Phony1} = > makedep_add_header( > + Ifile, Included, Line_Len, Main_Target, Phony, File), > + makedep_add_headers(Ifile, Rest, Included1, Line_Len1, > + Main_Target1, Phony1, Opts); > + false -> > + makedep_add_headers(Ifile, Rest, Included, Line_Len, > + Main_Target, Phony, Opts) > + end; > +makedep_add_headers(Ifile, [_ | Rest], Included, Line_Len, > + Main_Target, Phony, Opts) -> > + makedep_add_headers(Ifile, Rest, Included, > + Line_Len, Main_Target, Phony, Opts); > +makedep_add_headers(_Ifile, [], _Included, _Line_Len, > + Main_Target, Phony, _Opts) -> > + {Main_Target, Phony}. > + > +makedep_add_header(Ifile, Included, Line_Len, Main_Target, Phony, > File) -> > + case lists:member(File, Included) of > + true -> > + % This file was already listed in the dependencies, skip it. > + {Included, Line_Len, Main_Target, Phony}; > + false -> > + Included1 = [File | Included], > + % Remove "./" in front of the dependency filename. > + File1 = case lists:prefix("./", File) of > + true -> lists:nthtail(2, File); > + false -> File > + end, > + % Prepare the phony target name. > + Phony1 = case File of > + Ifile -> Phony; > + _ -> Phony ++ "\n\n" ++ File1 ++ ":" > + end, > + % Add the file to the dependencies. > + if > + Line_Len + 1 + length(File1) > 76 -> > + Line_Len1 = 2 + length(File1), > + Main_Target1 = Main_Target ++ " \\\n " ++ File1, > + {Included1, Line_Len1, Main_Target1, Phony1}; > + true -> > + Line_Len1 = Line_Len + 1 + length(File1), > + Main_Target1 = Main_Target ++ " " ++ File1, > + {Included1, Line_Len1, Main_Target1, Phony1} > + end > + end. > + > %% expand_module(State) -> State' > %% Do the common preprocessing of the input forms. > > > _______________________________________________ > erlang-patches mailing list > erlang-patches@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-patches Best regards -- Oscar Hellstr?m, oscar@REDACTED Phone: +44 (0)798 45 44 773 Mobile: +44 (0)207 65 50 337 Web: http://www.erlang-consulting.com From jean-sebastien.pedron@REDACTED Wed Oct 29 16:51:08 2008 From: jean-sebastien.pedron@REDACTED (=?UTF-8?B?SmVhbi1Tw6liYXN0aWVuIFDDqWRyb24=?=) Date: Wed, 29 Oct 2008 16:51:08 +0100 Subject: [erlang-patches] Producing dependencies Makefile for Erlang using erlc(1) In-Reply-To: <9303310.26291225294253246.JavaMail.root@zimbra> References: <9303310.26291225294253246.JavaMail.root@zimbra> Message-ID: <4908866C.8020408@dumbbell.fr> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 29.10.2008 16:30, Oscar Hellstr?m wrote: > How does this deal with header files included with -include_lib(). > For our build purposes we use a small shellscript to generate > dependencies, which also takes -include_lib directives into > consideration. "-include_lib" directives are expanded before the new options are treateed so it's supported. If we take the following module: -module(mod3). -include_lib("xmerl/include/xmerl.hrl"). ... The command "erlc -M mod3.erl" will output: mod3.beam: mod3.erl \ /usr/local/lib/erlang/lib/xmerl-1.1.10/include/xmerl.hrl > I must say that I really welcome this though :) Thanks! > Now we just support for pkg-config to be able to compile drivers > without pain as well. Yes, it would be great to have this :) - -- Jean-S?bastien P?dron http://www.dumbbell.fr/ PGP Key: http://www.dumbbell.fr/pgp/pubkey.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkkIhmwACgkQa+xGJsFYOlPvcQCfXK5XPNowRVxFocpjDeC1z3H0 Ae8AoKxxboK9brW2cohGJ9AxtZLySF4y =aaBI -----END PGP SIGNATURE----- From jay@REDACTED Thu Oct 30 05:14:42 2008 From: jay@REDACTED (Jay Nelson) Date: Wed, 29 Oct 2008 21:14:42 -0700 Subject: [erlang-patches] Patches to supervisor and sasl_report Message-ID: <69BFBA7F-048B-4AB4-B7D0-F0D40C92D61C@duomark.com> Any chance on either of my prior patches being incorporated in a future version? Any comments from the OTP team on either of them? http://www.erlang.org/pipermail/erlang-questions/2008-May/035065.html http://www.erlang.org/pipermail/erlang-questions/2008-May/035066.html jay From kenji.rikitake@REDACTED Fri Oct 31 00:46:19 2008 From: kenji.rikitake@REDACTED (Kenji Rikitake) Date: Fri, 31 Oct 2008 08:46:19 +0900 Subject: [erlang-patches] Revised version: Re: [erlang-bugs] leap-second-enabled FreeBSD doesn't work right with R12B4 erts/emulator/beam/erl_time_sup.c; correction patch included In-Reply-To: <20080918021602.GA6530@k2r.org> References: <20080914014111.GA7026@k2r.org> <20080914031210.GA9162@k2r.org> <20080914052418.GA10612@k2r.org> <20080918021602.GA6530@k2r.org> Message-ID: <20081030234619.GA31298@k2r.org> The previous patch I posted on September 18, 2008 had a bug in the new BIF erlang:now_utc/0 which I added. This patch is a revised one for R12B4, now also tested on a non-leap-second system (Ubuntu 8.04 LTS Desktop). Kenji Rikitake -------------- next part -------------- A non-text attachment was scrubbed... Name: erl_now_utc.patch Type: text/x-diff Size: 6770 bytes Desc: not available URL: