A minimal Standard Library

S

sandeep

I am now planning a masters thesis on my specialized subject of ANSI C.
There needs to be an original research in it.

I am thinking about working out what would be the minimal Standard
Library, i.e. all other standard library functions can be implemented in
terms of these minimal functions. Here are some examples:

* fopen is needed because opening files is platform specific
* strcpy is not needed because it can be implemented already in standard C
* if you have sprintf then you do not also need fprintf or printf because
they can be implemented using sprintf and other i/o functions

My questions are: has this already been done before? If not, would you
assess that it could be monetized if patented?

Thanks.
 
M

Malcolm McLean

I am thinking about working out what would be the minimal Standard
Library, i.e. all other standard library functions can be implemented in
terms of these minimal functions. Here are some examples:
No good, I'm afraid. The question isn't deep enough to get you a
Master's, and almost everyone who implements the standard library
looks at this question, so it's not original or patentable either.

However if you want a topic,

There's something that cannot be done in C, which is to build a
variable argument list at runtime. To my knowledge, this is the only
procedure of this nature which is unachievable. Are there any others,
and how would ypu add this facility to C?
 
C

Chris H

sandeep <[email protected]> said:
I am now planning a masters thesis on my specialized subject of ANSI C.

Then you have failed unless you are talking about the ANSI C standard of
1989. Since 1990 it has been superseded by ISO 9899 (1990, 93, 95, 99
etc.)
I am thinking about working out what would be the minimal Standard
Library, i.e. all other standard library functions can be implemented in
terms of these minimal functions.

See MISRA-C
Here are some examples:

* fopen is needed because opening files is platform specific

Not all platforms have file systems. The de-facto standard is the FAT
file systems though others exist and are used
* strcpy is not needed because it can be implemented already in standard C

SO can almost everything else.
* if you have sprintf then you do not also need fprintf or printf because
they can be implemented using sprintf and other i/o functions

You are in serious trouble here.
My questions are: has this already been done before?

Yes many times.
If not, would you
assess that it could be monetized if patented?

No and you WILL fail because you are looking at this the wrong wan and
for the wrong reasons.
 
N

Nick Keighley

I am now planning a masters thesis on my specialized subject of ANSI C.
There needs to be an original research in it.

it's actually ISO that publish the standard now

I am thinking about working out what would be the minimal Standard
Library, i.e. all other standard library functions can be implemented in
terms of these minimal functions.

Read PJ Plauger's library book

Here are some examples:

* fopen is needed because opening files is platform specific
* strcpy is not needed because it can be implemented already in standard C
* if you have sprintf then you do not also need fprintf or printf because
they can be implemented using sprintf and other i/o functions

My questions are: has this already been done before? If not, would you
assess that it could be monetized if patented?

I'm not exactly sure if its in my interest to help you patent
something like that...
 
N

Nick Keighley

No good, I'm afraid. The question isn't deep enough to get you a
Master's, and almost everyone who implements the standard library
looks at this question, so it's not original or patentable either.

However if you want a topic,

There's something that cannot be done in C, which is to build a
variable argument list at runtime. To my knowledge, this is the only
procedure of this nature which is unachievable. Are there any others,
and how would ypu add this facility to C?

longjmp, offsetof, fgetc (or some other i/o primitive), malloc is
probably going to need assistance from the platform
 
B

BGB / cr88192

No good, I'm afraid. The question isn't deep enough to get you a
Master's, and almost everyone who implements the standard library
looks at this question, so it's not original or patentable either.

However if you want a topic,

There's something that cannot be done in C, which is to build a
variable argument list at runtime. To my knowledge, this is the only
procedure of this nature which is unachievable. Are there any others,
and how would ypu add this facility to C?

<--
longjmp, offsetof, fgetc (or some other i/o primitive), malloc is
probably going to need assistance from the platform
-->

longjmp is often written in ASM.

offsetof is often a compiler builtin (sort of like sizeof).

fgetc is usually a wrapper for fread, for example:
int fgetc(FILE *fd)
{
unsigned char c;
if(fread(&c, 1, 1, fd)<=0)
return(EOF);
return(c);
}

rather than the other way around.


usually fread/fwrite/... are wrappers for OS primitives (such as
read/write/... in POSIX), which are usually implemented in terms of a
system-call type mechanism...

malloc is usually often implemented with assistance from the OS (such as
mmap or VirtualAlloc...).
I guess many older/simpler systems use a mechanism such a brk/sbrk, which
map memory in linearly (rather than into arbitrary locations in the address
space...).

....
 
S

sandeep

Malcolm said:
No good, I'm afraid. The question isn't deep enough to get you a
Master's, and almost everyone who implements the standard library looks
at this question, so it's not original or patentable either.

If it has been done before, please tell me a reference where it is
published so I can read and see how it can be extended.

I believe the question could end up very deep, with lots of complicated
interdependencies between standard library functions. In fact it may be
*too much* for a thesis!
 
S

sfuerst

No good, I'm afraid. The question isn't deep enough to get you a
Master's, and almost everyone who implements the standard library
looks at this question, so it's not original or patentable either.

However if you want a topic,

There's something that cannot be done in C, which is to build a
variable argument list at runtime. To my knowledge, this is the only
procedure of this nature which is unachievable. Are there any others,
and how would ypu add this facility to C?

Actually, if you know the ABI of your platform, this might be
possible. You just invoke implementation defined behaviour in just
the right way. The result is not standard C, but will be portable
between compilers since the ABI is standardized on your platform.

An example for the Sys-V ABI used in linux on x86-64 is at
http://locklessinc.com/articles/c_abi_hacks/
Of course, using a FFI library written in assembly is much more
efficient... but that's not the point of the exercise.

Steven
 
N

Nick Keighley

<--
longjmp, offsetof, fgetc (or some other i/o primitive), malloc is
probably going to need assistance from the platform
-->

longjmp is often written in ASM.

he wanted examples of standard library things that couldn't be written
in standard C.

If it's written in assembler I'd suggest it *definitely* wasn't
written in C!!
offsetof is often a compiler builtin (sort of like sizeof).

maybe. Often some trickery is done with pointer arithmatic (lifted
from wikipedia)

#define offsetof(st, m) \
((size_t) ( (char *)&((st *)(0))->m - (char *)0 ))

either way *** it isn't written in C ***

fgetc is usually a wrapper for fread, for example:
int fgetc(FILE *fd)
{
    unsigned char c;
    if(fread(&c, 1, 1, fd)<=0)
        return(EOF);
    return(c);

}
rather than the other way around.

this is why I said "or some other i/o primitive"

usually fread/fwrite/... are wrappers for OS primitives (such as
read/write/... in POSIX), which are usually implemented in terms of a
system-call type mechanism...

which isn't standard C
malloc is usually often implemented with assistance from the OS (such as
mmap or VirtualAlloc...).

I said that
I guess many older/simpler systems use a mechanism such a brk/sbrk, which
map memory in linearly (rather than into arbitrary locations in the address
space...).

but again requires OS assistance.

And all the world isn't Unix.
 
E

Eric Sosman

If it has been done before, please tell me a reference where it is
published so I can read and see how it can be extended.

I believe the question could end up very deep, with lots of complicated
interdependencies between standard library functions. In fact it may be
*too much* for a thesis!

Given the elementary nature of the questions you've been asking
here recently, and some of the fundamental misunderstandings those
questions reveal, I'd hazard a guess that it's too much for *your*
thesis.

Seriously: You're planning to write a Master's thesis about C,
a language you do not know. Unless your degree-granting institution
evaluates theses by weight or something, I don't see how any thesis
jury would accept your effort at your present level of expertise.
You are not a Master; you're not even an Apprentice yet. I urge you
either to learn C before embarking on this project, or to choose a
subject area you know something about. As things stand, you are
doomed to fail -- unless, as I say, your jury cares more about font
choice than about content.
 
N

Nobody

* if you have sprintf then you do not also need fprintf or printf because
they can be implemented using sprintf and other i/o functions

Maybe. Implementing fprintf() atop sprintf() requires that you
can allocate an array large enough to hold the entire string. "Real"
fprintf() implementations typically don't have this limitation.

OTOH, using sprintf() is probably legal in spite of the drawbacks.
 
R

Rui Maciel

sandeep said:
My questions are: has this already been done before? If not, would you
assess that it could be monetized if patented?

What exactly do you expect to patent? A subset of features offered by a standard library?


Rui Maciel
 
K

Keith Thompson

Nick Keighley said:
he wanted examples of standard library things that couldn't be written
in standard C.

If it's written in assembler I'd suggest it *definitely* wasn't
written in C!!

I don't think he was suggesting otherwise.
maybe. Often some trickery is done with pointer arithmatic (lifted
from wikipedia)

#define offsetof(st, m) \
((size_t) ( (char *)&((st *)(0))->m - (char *)0 ))

either way *** it isn't written in C ***

Hmm? The macro implementation ceratainly is written in C; it just
isn't written in portable C.

For that matter, with sufficient compiler support the entire standard
library can be written in (non-portable) C:

FILE *fopen(const char *path, const char *mode)
{
return __builtin_fopen(path, mode);
}

I suppose the question is, what set of primitives is sufficient to
allow the entire standard library to be implemented in otherwise
portable standard C plus those primitives? I'm not at all convinced
that it's a deep enough question for a master's thesis.
 
I

ImpalerCore

I am now planning a masters thesis on my specialized subject of ANSI C.
There needs to be an original research in it.

I am thinking about working out what would be the minimal Standard
Library, i.e. all other standard library functions can be implemented in
terms of these minimal functions. Here are some examples:

* fopen is needed because opening files is platform specific
* strcpy is not needed because it can be implemented already in standard C
* if you have sprintf then you do not also need fprintf or printf because
they can be implemented using sprintf and other i/o functions

My questions are: has this already been done before? If not, would you
assess that it could be monetized if patented?

Thanks.

That sounds extremely boring to me. If you're doing a research
project, it should at least capture your imagination, because if the
topic is really interesting to you, you'll have the motivation to
spend the time necessary to get it accomplished. I would think your
advisor should have topics of research that you can pursue that would
be more interesting than this. Or maybe cross over to another
department (engineering, business) and find a project that gives you
the scope needed for a master's thesis.

And at the master's level, it's getting harder and harder to find
threads of undiscovered work that can be completed in a reasonable
amount of time. Even doing something that's already been done, but do
it in a different way that you can compare and contrast is often times
good enough. It's the PH.D. degrees that usually have to come up with
something truly novel in their field.
 
U

Uno

Richard said:
Start with "The Standard C Library", by P J Plauger.

Plauger's a legend, and his fingerprints are all over Dinkumware. This
book is Promethean, and P.J. is the type of nice guy who sends you the
source for the price of polite request.

The best things in life really are free. (Except massages.)
 
A

Andrew Smallshaw

I am thinking about working out what would be the minimal Standard
Library, i.e. all other standard library functions can be implemented in
terms of these minimal functions. Here are some examples:
My questions are: has this already been done before? If not, would you
assess that it could be monetized if patented?

No, it is not a new idea. In the early days of C there were a
number of replacment standard libraries out there to address
shortcomings in the vendor-supplied library. I still have one of
those from JPL lying around here - I'll send you a copy if you
want, it's only around 150kb. To quote the manual:

The system I/O interface is restricted to the functions sbrk,
close, creat, exit, lseek, open, read, unlink, and write,
supplied by the host C language vendor. These are assumed to be
compatible with UNIXtm conventions...

Those files are timestamped 1986 when the standard library was a
more vaguely defined concept than it is today (pre ANSI standardisation)
but the idea still holds. It also means there is at least 24 years
prior art on your idea.
 
E

Ed

sandeep said:
I am now planning a masters thesis on my specialized subject of ANSI C.
There needs to be an original research in it.

I am thinking about working out what would be the minimal Standard
Library, i.e. all other standard library functions can be implemented
in
terms of these minimal functions. Here are some examples:

* fopen is needed because opening files is platform specific
* strcpy is not needed because it can be implemented already in
standard C
* if you have sprintf then you do not also need fprintf or printf
because
they can be implemented using sprintf and other i/o functions

My questions are: has this already been done before?

Yes, many times. Sources are operating system research and development.
They have in the past implemented just the bare essentials to get some
existing code to compile.
If not, would you assess that it could be monetized if patented?

If you can find a remote patent in there somewhere, want to go through
the expensive patent process, power to ya. It sounds like a waste of
time. C is, of course, in permanent mothball mode. The guy doing
R&D/self-training with LCC is probably someone you want to interview to
get a slightly larger scope of view.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top