mirror of
https://github.com/cahirwpz/libnix.git
synced 2025-11-19 16:00:58 +00:00
Move sources root to main directory.
This commit is contained in:
30
examples/Makefile.in
Normal file
30
examples/Makefile.in
Normal file
@ -0,0 +1,30 @@
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
CC = @CC@
|
||||
|
||||
#### End system configuration section ####
|
||||
|
||||
# Some examples
|
||||
|
||||
.PHONY: all
|
||||
|
||||
all: lib libr dev helloworld
|
||||
|
||||
# normal library
|
||||
lib: libinit.o simplelib.c
|
||||
$(CC) -nostdlib -O3 -fomit-frame-pointer -fbaserel $^ -o $@
|
||||
|
||||
# multibase library
|
||||
libr: libinitr.o simplelib.c
|
||||
$(CC) -nostdlib -O3 -fomit-frame-pointer -resident $^ -o $@
|
||||
|
||||
# device
|
||||
dev: devinit.o simpledev.c
|
||||
$(CC) -nostdlib -O3 -fomit-frame-pointer -fbaserel $^ -o $@
|
||||
|
||||
# helloworld
|
||||
helloworld: nbcrt0.o helloworld.c libstubs.a
|
||||
$(CC) -nostdlib -O3 -fomit-frame-pointer -s -fbaserel $^ -o $@
|
||||
20
examples/helloworld.c
Normal file
20
examples/helloworld.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include <dos/dos.h>
|
||||
#include <workbench/workbench.h>
|
||||
#include <inline/exec.h>
|
||||
#include <inline/dos.h>
|
||||
|
||||
int __nocommandline=1; /* Disable commandline parsing */
|
||||
int __initlibraries=0; /* Disable auto-library-opening */
|
||||
|
||||
struct DosLibrary *DOSBase=NULL;
|
||||
|
||||
extern struct WBStartup *_WBenchMsg;
|
||||
|
||||
int main(void)
|
||||
{ if(_WBenchMsg==NULL)
|
||||
{ if((DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",33))!=NULL)
|
||||
{ Write(Output(),"Hello world\n",12);
|
||||
CloseLibrary((struct Library *)DOSBase); } }
|
||||
return 0;
|
||||
}
|
||||
|
||||
149
examples/simpledev.c
Normal file
149
examples/simpledev.c
Normal file
@ -0,0 +1,149 @@
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* includes */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
#include <exec/errors.h>
|
||||
#include <proto/exec.h>
|
||||
#include "stabs.h"
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* exports */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
const char DevName[]="simple.device";
|
||||
const char DevIdString[]="version 1.0";
|
||||
|
||||
const UWORD DevVersion=1;
|
||||
const UWORD DevRevision=0;
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* global declarations */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
struct Device *myDevPtr;
|
||||
struct ExecBase *SysBase;
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* user device initialization */
|
||||
/* */
|
||||
/* !!! CAUTION: This function runs in a forbidden state !!! */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
int __UserDevInit(struct Device *myDev)
|
||||
{
|
||||
/* !!! required !!! */
|
||||
SysBase = *(struct ExecBase **)4L;
|
||||
|
||||
/* setup your device base - to access device functions over *this* basePtr! */
|
||||
|
||||
myDevPtr = myDev;
|
||||
|
||||
/* now do your initialization */
|
||||
|
||||
/* ... */
|
||||
|
||||
/* return a bool to indicate success */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* user device cleanup */
|
||||
/* */
|
||||
/* !!! CAUTION: This function runs in a forbidden state !!! */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
void __UserDevCleanup(void)
|
||||
{
|
||||
/* your cleanup comes here */
|
||||
|
||||
/* ... */
|
||||
|
||||
/* nothing to return */
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* device dependent open function */
|
||||
/* */
|
||||
/* !!! CAUTION: This function runs in a forbidden state !!! */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
int __UserDevOpen(struct IORequest *iorq,ULONG unit,ULONG flags)
|
||||
{
|
||||
int io_err = IOERR_OPENFAIL;
|
||||
|
||||
/* return a bool to indicate success */
|
||||
|
||||
return io_err;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* device dependent close function */
|
||||
/* */
|
||||
/* !!! CAUTION: This function runs in a forbidden state !!! */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
void __UserDevClose(struct IORequest *iorq)
|
||||
{
|
||||
/* nothing to return */
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* device dependent beginio function */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
ADDTABL_1(__BeginIO,a1);
|
||||
|
||||
void __BeginIO(struct IORequest *iorq)
|
||||
{
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* device dependent abortio function */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
ADDTABL_1(__AbortIO,a1);
|
||||
|
||||
void __AbortIO(struct IORequest *iorq)
|
||||
{
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* additional device dependent functions */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* endtable marker (required!) */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
ADDTABL_END();
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* end of simpledev.c */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
91
examples/simplelib.c
Normal file
91
examples/simplelib.c
Normal file
@ -0,0 +1,91 @@
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* includes */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
#include <dos/dosextens.h>
|
||||
#include <proto/exec.h>
|
||||
#include "stabs.h"
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* exports */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
const char LibName[]="simple.library";
|
||||
const char LibIdString[]="version 1.0";
|
||||
|
||||
const UWORD LibVersion=1;
|
||||
const UWORD LibRevision=0;
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* global declarations */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
struct Library *myLibPtr;
|
||||
struct ExecBase *SysBase;
|
||||
struct DosLibrary *DOSBase;
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* user library initialization */
|
||||
/* */
|
||||
/* !!! CAUTION: This function may run in a forbidden state !!! */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
int __UserLibInit(struct Library *myLib)
|
||||
{
|
||||
/* setup your library base - to access library functions over *this* basePtr! */
|
||||
|
||||
myLibPtr = myLib;
|
||||
|
||||
/* !!! required !!! */
|
||||
SysBase = *(struct ExecBase **)4L;
|
||||
|
||||
return (DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",33L))==NULL;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* user library cleanup */
|
||||
/* */
|
||||
/* !!! CAUTION: This function runs in a forbidden state !!! */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
void __UserLibCleanup(void)
|
||||
{
|
||||
CloseLibrary(&DOSBase->dl_lib);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* library dependent function(s) */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
ADDTABL_1(__UserFunc,d0); /* One Argument in d0 */
|
||||
|
||||
int __UserFunc(long a)
|
||||
{
|
||||
return a*2;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* endtable marker (required!) */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
ADDTABL_END();
|
||||
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* end of simplelib.c */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
Reference in New Issue
Block a user