mailing list of musl libc
 help / color / mirror / code / Atom feed
From: u-uy74@aetey.se
To: musl@lists.openwall.com
Subject: (OT?) replying two years later (was: Removing sbrk and brk)
Date: Wed, 13 Apr 2016 15:39:19 +0200	[thread overview]
Message-ID: <20160413133919.GO25745@example.net> (raw)

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

This is not about musl but about a musl-compatibility of some
respectable software :)

2014-02-21 23:34 GMT+1 Daniel Cegiełka wrote:
> 2014-02-21 18:09 GMT+01:00 Rich Felker <dalias@...ifal.cx>:
> 
> > Then it didn't work before either; it was silently corrupting memory.
> > The only difference now is that you know that it's not working.
> 
> Thank you for your response and I understand the reasons.
> In my free time I will try to fix ex/vi ...

FWIIW.

I did not find anyone else having built a working ex-vi with musl.

As a quick hack, given the absence of threading:
an additional file sbrk.c (attached)
and "make MALLOC=sbrk.o" do the trick for ex-vi, at least on ia32.

(I also removed the "poolsbrk(0);" call from ex.c and exrecover.c,
instead of adding a dummy function. A more elaborated fake sbrk might
use it for initialization of course.)

May be this will be useful to someone, while building old stuff.
This may also further mitigate the motivation/need for sbrk() in musl.

Allocating "a lot of" unused memory should not hurt much on modern Linux
with MMU, adding support for negative increments is straightforward
if there are programs making heavy use of such a feature.

Cheers,
Rune

[-- Attachment #2: sbrk.c --]
[-- Type: text/plain, Size: 597 bytes --]

/*
 * fake sbrk implementation by RL @ Aetey Global Technologies AB
 * 2016-04-13
 * put in public domain by the author
 */

#include <errno.h>
#include <sys/types.h>

/* preallocate 10 Mbyte */
#define POOLSIZE 10485760

static char brkspace[POOLSIZE];
static int  brki = 0;

void *sbrk(intptr_t incr) {
  int prev;
/* do not mind leaking memory on negative incr,
 * ex does not seem to use this */
  if (incr <= 0)
    return (void *)(brkspace+brki);
  if (incr > POOLSIZE-brki) {
    errno = ENOMEM;
    return (void *)-1;
  }
  prev = brki;
  brki += incr;
  return (void *)(brkspace+prev);
}

                 reply	other threads:[~2016-04-13 13:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20160413133919.GO25745@example.net \
    --to=u-uy74@aetey.se \
    --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).