mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jens Gustedt <jens.gustedt@inria.fr>
To: musl@lists.openwall.com
Subject: Re: build with clang-3.4 warnings report
Date: Sun, 06 Apr 2014 00:08:23 +0200	[thread overview]
Message-ID: <1396735703.11744.355.camel@eris.loria.fr> (raw)
In-Reply-To: <20140405163512.GW26358@brightrain.aerifal.cx>


[-- Attachment #1.1: Type: text/plain, Size: 1387 bytes --]

Am Samstag, den 05.04.2014, 12:35 -0400 schrieb Rich Felker:
> I'd be interested in seeing what you mean by some of these, but note
> that these are all +'s and don't seem to have any concrete advantages
> over the current code.

I attach the cleanest and simplest version. (forget about the handling
of the historic mips case, if you don't like it)

> I was talking about the approach with designated initializers, which I
> assumed would look something like:
> 
> {
> 	[EBADF] = "Bad file descriptor",
> 	[EILSEQ] = "Illegal sequence",
> 	...
> }

sorry I wasn't clear enough, yes the one you had in mind would need an
array of pointers, instead of "unsigned char".

I was thinking of using designated initializers to compute offsets. In
the example that is joint, the main change in size is due to the
change from "unsigned char" to "unsigned short" for the table and
because there are some holes. (+200)

When placing the default entry in front instead of last, this shaves
of about 50, again. (so +150 in total)

Jens


-- 
:: INRIA Nancy Grand Est :: http://www.loria.fr/~gustedt/   ::
:: AlGorille ::::::::::::::: office Nancy : +33 383593090   ::
:: ICube :::::::::::::: office Strasbourg : +33 368854536   ::
:: ::::::::::::::::::::::::::: gsm France : +33 651400183   ::
:: :::::::::::::::::::: gsm international : +49 15737185122 ::




[-- Attachment #1.2: strerror.c --]
[-- Type: text/x-csrc, Size: 1242 bytes --]

#include <errno.h>
#include <string.h>
#include <stddef.h>

/* mips has one error code outside of the 8-bit range due to a
 * historical typo, so we just remap it. */
#define MIPSACCIDENT 1133

#if EDQUOT==MIPSACCIDENT
# define MIPSSPECIAL (MIPSACCIDENT&0xFF)
# undef EDQUOT
# define EDQUOT MIPSSPECIAL
#else
# define MIPSSPECIAL 0
#endif


#define E(a,b) char _err ## a[sizeof b];
struct errstruct {
#include "__strerror.h"
};

#undef E
#define E(a,b) ._err ## a = { b },
static const struct errstruct errmsg = {
#include "__strerror.h"
};

#undef E
#define E(a,b) [a] = offsetof(struct errstruct, _err ## a),
static const unsigned short erroffset[] = {
#include "__strerror.h"
};

enum { errmax = (sizeof erroffset)/(sizeof erroffset[0]), };

char *strerror(int e)
{
        if (MIPSSPECIAL) {
          switch (e) {
            /* would be simpler if _err0 would be first field */
          case MIPSSPECIAL: return (char*)errmsg._err0;
          case MIPSACCIDENT: e=MIPSSPECIAL; break;
          }
        }
        /* would be simpler if _err0 would be first field */
        if (((unsigned)e >= (unsigned)errmax) || !erroffset[e]) e = 0;
        return erroffset[e] + (char*)&errmsg;
}

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2014-04-05 22:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-04 19:59 Abdoulaye Walsimou Gaye
2014-04-04 20:47 ` Rich Felker
2014-04-05  1:06   ` Abdoulaye Walsimou Gaye
2014-04-05  1:54     ` Rich Felker
2014-04-05  9:04       ` Jens Gustedt
2014-04-05  9:31         ` Szabolcs Nagy
2014-04-05 13:07         ` Rich Felker
2014-04-05 14:37           ` Jens Gustedt
2014-04-05 16:35             ` Rich Felker
2014-04-05 22:08               ` Jens Gustedt [this message]
2014-04-06  1:57                 ` Rich Felker
2014-04-06 16:37                   ` Jens Gustedt
2014-04-06 16:49                     ` Rich Felker
2014-04-07 11:17       ` Oliver Schneider
2014-04-07 17:23         ` Rich Felker
2014-04-07 19:40           ` Abdoulaye Walsimou Gaye

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1396735703.11744.355.camel@eris.loria.fr \
    --to=jens.gustedt@inria.fr \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

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).