This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Tech question RE: STDIO primitives
- To: help-gcc at gnu dot org
- Subject: Tech question RE: STDIO primitives
- From: A-Du-ReaNOGI at EsperNOGO dot Com (Art Du Rea: NoGargbageIn:NoGarbageOut)
- Date: Thu, 26 Aug 1999 23:01:00 GMT
- Newsgroups: gnu.gcc.help
- Xref: wodc7nx0 gnu.gcc.help:710
Illustrious and Celebrated Participants and Lurkers:
I'm very new to this group, but thought it is a good place for this topic. It was
originally posted in "comp.dsp" where I normally hang out ...
I am nearly finished writing a STDIO "primitives" package for Motorola (GNU) C so that a PC
running HyperTerminal to a Com port can be used as a STDIO console terminal for Motorola DSP
EVM Evaluation Boards (starting with the DSP56307EVM). Of course I'm
champing at the bit to get it finished.
I have run into one confusing point regarding "count parmeters" in the universal "streams"
I/O primitives calls ... there are TWO of them, but no explanation as to why there are 2.
Here goes! The documentation at the end of this message pretty much says everything I think
I know about STDIO calls, so if you would, please read just the first paragraph of the
definition for now (if there are any misconceptions, PLEASE let me know!).
In the first call to "send", the 3rd member of the parameter array (passed by reference) is
a member count, but I don't know EXACTLY what is being counted, because there is ANOTHER
member count explicitly passed as the second parameter in the 2nd call to "send".
My question is: "what is the difference between the count parameters, and why are there 2 of
them?".
A 2nd, but more basic question, is: "Is it true that the primitive calling sequence for File
streams operations is ALWAYS 3 and ONLY 3 calls ... the first 2 to "send" and the last one
to "recv"?". I have this haunting suspicion that just maybe the "middle" call to transfer
data may be callable MORE than once. That would put a whole new wrinkle on the STDIO
handler state machine! How would I know when the operation was finished?
Now, I'll give you my suspicions regarding the 1st question ... I suspect that there are 2
counts so that the PHYSICAL SIZE of the allocated buffer can be passed to the streams
handler (STDIO) in one of them, and the ACTUAL COUNT of data members can be passed in the
other. The physical size probably goes in the 3rd member of the parameter array, and the
actual count is the 2nd parameter of the 2nd call to "send". This would provide part of the
mechanism to allow a very large file to be processed when the available buffer is
"not-quite-so-large". Is this guess even close to correct?
This is all probably a moot point for STDIO because the allocated data buffer should always
be big enough for the entire data set to be transferred with 1 call, but I want to be sure I
don't foul something up in my state-machine code. As you can see, I sort of like to
understand what I am doing. That's what happens when you send an engineer to do a
programmer's job! (grin)
I would sincerely appreciate any gracious assistance or referrals. Hopefully, this will
wrap things up on my project! Thank you so very much.
All the best, and ENJOY!
Art Du Rea
a-du-rea@esper.com
Systems Engineering Consultant
Knoxville, Tennessee, USA
NOTE: FORMATTED FOR MONOSPACE FONT!
/*****************************************************************************/
/******** COMPREHENSIVE STANDARD I/O INFORMATION ********/
/******** COPYRIGHT (c) 1999 Arthur W. Du Rea, Jr. ********/
/******** ALL RIGHTS RESERVED ********/
/*****************************************************************************/
/*
A MINIMAL DEFINITION OF STDIO PRIMITIVE CALL TRIPLETS:
=====================================================
All STDIO calls are made in groups of 3 primitive calls. The first 2 calls are made to
function "send", and the final status call is made to function "recv". The 1st call passes
the operational parameters to the STDIO handler. The 2nd call sends a pointer to a data
buffer and the data count, and also starts the actual I/O operation. The 3rd call provides
a pointer to an array for returning the completion status of the STDIO operation.
"send" Prototype ("void *" because data type of 2nd call is not known!)
void __send (void * info_pointer, int how_many)
"recv" Prototype
void __recv (int * stat_array)
FIRST CALL - "info_pointer" points to a 3 member int array of parameters
"how_many" is 3 - there are 3 parameters in the command_array
int command_array[3];
command_array[0] = Command Type
type is "int" DSP_READ or DSP_WRITE (from ioprim.h)
command_array[1] = Descriptor Index
type is "int" Index into an array of type FILE structures
Index to stdin = 0, stdout = 1, stderr = 2 (hard coded)
(see file stdio.h)
command_array[2] = nmemb
type is "size_t", which auto casts to int
Number of members
__send (command_array, 3)
SECOND CALL - "info_pointer" points to an existing buffer
"how_many" is the number of members to read or write
__send (data_pointer, nmemb)
THIRD CALL - "stat_array" points to a 2 member int status array
int stat_array[2];
stat_array[0] = Completion Code
type is "int" SUCCESS = 0, FAIL = -1
stat_array[1] = ERRNO
type is "int" (see file ioprim.h)
__recv (stat_array)
*/
/* EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF */
All the best, and ENJOY!
Art Du Rea
Knoxville, Tennessee, USA
(Remove NOGI:NOGO for direct e-mail)
All the best, and ENJOY!
Art Du Rea
Knoxville, Tennessee, USA
(Remove NOGI:NOGO for direct e-mail)