How to use newlib

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: How to use newlib

Post by JamesM »

LoseThos wrote:I take it you're making a linux clone?
No, I'm not. The OS I'm making has pluggable syscall subsystems, one of which happens to be POSIX so GNU apps can be run, however the native syscall subsystem is completely different from POSIX.
LoseThos
Member
Member
Posts: 112
Joined: Tue Oct 30, 2007 6:41 pm
Location: Las Vegas, NV USA
Contact:

Re: How to use newlib

Post by LoseThos »

Any decent programmer knows it's quicker and more pleasant writing from scratch and only bosses and programmers without skills spout-off "Not invented here."

I am so frustrated with the state of sound on PC's. All i need is a pair of buffered digital to analog converters. I made a A-to-D/D-to-A ISA card years ago. I'm not kidding when I say I could make a sound card faster then figure-out how to program existing ones without documentation.
Last edited by LoseThos on Mon Dec 08, 2008 8:11 am, edited 1 time in total.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: How to use newlib

Post by JamesM »

LoseThos wrote:Any decent programmer knows it's quicker and more pleasant writing from scratch
:shock: Did you really just say that?
LoseThos
Member
Member
Posts: 112
Joined: Tue Oct 30, 2007 6:41 pm
Location: Las Vegas, NV USA
Contact:

Re: How to use newlib

Post by LoseThos »

It's an exaduration, but sometimes true. I find it more pleasant doing my own stuff and generally hate those who suggest every little widget should be off-the-shelf.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: How to use newlib

Post by AJ »

LoseThos wrote:Any decent programmer knows it's quicker and more pleasant writing from scratch
IMO, this only applies when components and existing code are poorly written and maintained.
LoseThos wrote:only bosses and programmers without skills spout-off "Not invented here."
What about programmers who want to use well tried and tested code, or compatibility with existing solutions?

Cheers,
Adam
LoseThos
Member
Member
Posts: 112
Joined: Tue Oct 30, 2007 6:41 pm
Location: Las Vegas, NV USA
Contact:

Re: How to use newlib

Post by LoseThos »

You know what you want to do better than I do. If you know anything about old formats, they tend to be "crufty", like FAT32 with the 8.3 names. I would hate to see a new operating system begin with a executable format dating to 32-bit days instead of 64-bit. Look-up on wikipedia the formats of .WAV files to .SND. The .WAV files are a monstrocity. Imagine trying to use MS Word documents as source files. That would be cool, but you just know the format of .DOC files is crufty. I think it takes thousands of pages to describe. Formats which have been around for a while grow ugly over time.
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Re: How to use newlib

Post by DeletedAccount »

hi ,
Although I do not agree much with you . There are lots of library and code available that its simply better to reuse them than reinvent the wheel . But it sometimes make me look like an idiot . when I proudly say that "I have implemented XYZ() ;", Someone else might say there is a method in some super namespace that does it . Yes C# has a good reputation of making me look like a moron :)

Regards
Shrek
AntiRush
Posts: 5
Joined: Wed Sep 10, 2008 9:29 am

Re: How to use newlib

Post by AntiRush »

LoseThos wrote:...only bosses and programmers without skills spout-off "Not invented here."
I believe you are using a pejorative term completely backwards. Not Invented Here is a term used to describe the very methodology you are espousing.
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: How to use newlib

Post by quanganht »

I found out that Newlib has provided syscalls in /libc/syscalls. But I don't understand. For example, 'write' function was implemented in syswrite.c, which then call _write or _write_r, and '_write' and '_write_r' is defined external. So what do I have to implement? write or _write or _write_r or all? And how to do that? :oops:
"Programmers are tools for converting caffeine into code."
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: How to use newlib

Post by JamesM »

quanganht wrote:I found out that Newlib has provided syscalls in /libc/syscalls. But I don't understand. For example, 'write' function was implemented in syswrite.c, which then call _write or _write_r, and '_write' and '_write_r' is defined external. So what do I have to implement? write or _write or _write_r or all? And how to do that? :oops:
RTFM. Also, look at the header file newlib/libc/include/reent.h:

Code: Select all

/* This header file provides the reentrancy.  */

/* The reentrant system calls here serve two purposes:

   1) Provide reentrant versions of the system calls the ANSI C library
      requires.
   2) Provide these system calls in a namespace clean way.

   It is intended that *all* system calls that the ANSI C library needs
   be declared here.  It documents them all in one place.  All library access
   to the system is via some form of these functions.

   There are three ways a target may provide the needed syscalls.

   1) Define the reentrant versions of the syscalls directly.
      (eg: _open_r, _close_r, etc.).  Please keep the namespace clean.
      When you do this, set "syscall_dir" to "syscalls" and add
      -DREENTRANT_SYSCALLS_PROVIDED to newlib_cflags in configure.host.

   2) Define namespace clean versions of the system calls by prefixing
      them with '_' (eg: _open, _close, etc.).  Technically, there won't be
      true reentrancy at the syscall level, but the library will be namespace
      clean.
      When you do this, set "syscall_dir" to "syscalls" in configure.host.

   3) Define or otherwise provide the regular versions of the syscalls
      (eg: open, close, etc.).  The library won't be reentrant nor namespace
      clean, but at least it will work.
      When you do this, add -DMISSING_SYSCALL_NAMES to newlib_cflags in
      configure.host.

   Stubs of the reentrant versions of the syscalls exist in the libc/reent
   source directory and are used if REENTRANT_SYSCALLS_PROVIDED isn't defined.
   They use the native system calls: _open, _close, etc. if they're available
   (MISSING_SYSCALL_NAMES is *not* defined), otherwise open, close, etc.
   (MISSING_SYSCALL_NAMES *is* defined).  */

/* WARNING: All identifiers here must begin with an underscore.  This file is
   included by stdio.h and others and we therefore must only use identifiers
   in the namespace allotted to us.  */
James
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: How to use newlib

Post by quanganht »

Oh, I see...
"Programmers are tools for converting caffeine into code."
LoseThos
Member
Member
Posts: 112
Joined: Tue Oct 30, 2007 6:41 pm
Location: Las Vegas, NV USA
Contact:

Re: How to use newlib

Post by LoseThos »

It's silly to argue over "Not invented here..." If I say "Do unto others...", you know the saying, right? My usage was completely clear since I clearly was arguing against those who mention "Not invented here syndrome".

"Pejoritive"? Aren't you a fancy pants.

Have to break-out some Godtalk on your butt. He uses high falootin words.

God says...
The moderators want LoseThos to SHUT UP.
I have a saying "Chess nuts boasting in an open foyer."
Post Reply