├── README.txt ├── source ├── COPYING ├── Makefile ├── README ├── doc │ ├── TeXmacros │ │ ├── lgrind.sty │ │ ├── myalpha.bst │ │ └── mystyle.sty │ ├── man │ │ ├── Makefile │ │ ├── README │ │ └── u++.1 │ └── refman │ │ ├── Actor.fig │ │ ├── Actor.tex │ │ ├── BinaryInsertionSort.tex │ │ ├── ClientINETSTREAM.tex │ │ ├── ClientServerConnected.fig │ │ ├── ClientServerConnected.tex │ │ ├── ClientServerUnconnected.fig │ │ ├── ClientServerUnconnected.tex │ │ ├── ClientUNIXDGRAM.tex │ │ ├── CyclicFullCoroutine.fig │ │ ├── CyclicFullCoroutine.tex │ │ ├── DSLNodes.fig │ │ ├── DSLNodes.tex │ │ ├── DSLQueue.fig │ │ ├── DSLQueue.tex │ │ ├── DSLSequence.fig │ │ ├── DSLSequence.tex │ │ ├── DSLStack.fig │ │ ├── DSLStack.tex │ │ ├── DirectComm.fig │ │ ├── DirectComm.tex │ │ ├── File.tex │ │ ├── LOOK.tex │ │ ├── Makefile │ │ ├── MonAcceptBB.tex │ │ ├── MonConditionBB.tex │ │ ├── README │ │ ├── RWEx1.tex │ │ ├── ReadyQueue.fig │ │ ├── ReadyQueue.tex │ │ ├── RunTimeStructure.fig │ │ ├── RunTimeStructure.tex │ │ ├── SemaphoreBB.tex │ │ ├── ServerINETSTREAM.tex │ │ ├── ServerStructures.fig │ │ ├── ServerStructures.tex │ │ ├── ServerUNIXDGRAM.tex │ │ ├── TaskAcceptBB.tex │ │ ├── TraceMsg.fig │ │ ├── TraceMsg.pstex │ │ ├── TraceMsg.pstex_t │ │ ├── TraceMsg.tex │ │ ├── uC++.bbl │ │ ├── uC++.ind │ │ ├── uC++.pretex │ │ ├── uC++.tex │ │ ├── uC++MutexObject.fig │ │ └── uC++MutexObject.tex ├── gdb │ ├── .gdbinit │ ├── README │ ├── utils-gdb.gdb │ └── utils-gdb.py └── src │ ├── MakeDefinitions │ ├── MakeRecipes │ ├── MakeTools │ ├── collection │ ├── Makefile │ ├── uBitSet.h │ ├── uBoundedBuffer.h │ ├── uCollection.h │ ├── uFlexArray.h │ ├── uHeap.h │ ├── uQueue.h │ ├── uSequence.h │ ├── uStack.h │ └── uStackLF.h │ ├── debugger │ ├── ArchBasics.h │ ├── LangBasics.h │ ├── Makefile │ ├── uBConditionEval.cc │ ├── uBConditionEval.h │ ├── uDebuggerAPI.h │ ├── uDebuggerProtocolUnit.cc │ ├── uDebuggerProtocolUnit.h │ ├── uLocalDebugger.cc │ ├── uLocalDebugger.h │ ├── uMakeBPstubs-alpha │ ├── uMakeBPstubs-arm_64 │ ├── uMakeBPstubs-hppa │ ├── uMakeBPstubs-i386 │ ├── uMakeBPstubs-ia64 │ ├── uMakeBPstubs-m68k │ ├── uMakeBPstubs-mips │ ├── uMakeBPstubs-rs6000 │ ├── uMakeBPstubs-sparc │ ├── uMakeBPstubs-unknown │ └── uMakeBPstubs-x86_64 │ ├── examples │ ├── AbortExit.cc │ ├── Accept.cc │ ├── ActorChameneos.cc │ ├── ActorDeviceDriver.cc │ ├── ActorDeviceDriver.data │ ├── ActorFib1.cc │ ├── ActorFib2.cc │ ├── ActorFib3.cc │ ├── ActorFib4.cc │ ├── ActorFork.cc │ ├── ActorFork2.cc │ ├── ActorHello.cc │ ├── ActorInherit.cc │ ├── ActorMatrixSum.cc │ ├── ActorPhoneNo.cc │ ├── ActorPhoneNo.data │ ├── ActorPingPong.cc │ ├── ActorProdCons.cc │ ├── ActorPromise.cc │ ├── ActorRestart.cc │ ├── ActorRing.cc │ ├── ActorSieve.cc │ ├── ActorTrace.cc │ ├── AlarmClock.cc │ ├── Allocation.cc │ ├── Array.cc │ ├── Atomic.cc │ ├── Bench.cc │ ├── BinaryInsertionSort.cc │ ├── BitSet.cc │ ├── CRAII.cc │ ├── Cobegin.cc │ ├── CorFullProdCons.cc │ ├── CorFullProdConsStack.cc │ ├── CorSemiProdCons.cc │ ├── DatingNew.cc │ ├── DatingTask.cc │ ├── DatingTrad.cc │ ├── DeleteProcessor.cc │ ├── Disinherit.cc │ ├── Disinherit1.cc │ ├── Disinherit1Static.cc │ ├── DisinheritStatic.cc │ ├── EHM1.cc │ ├── EHM10.cc │ ├── EHM11.cc │ ├── EHM2.cc │ ├── EHM3.cc │ ├── EHM4.cc │ ├── EHM5.cc │ ├── EHM6.cc │ ├── EHM7.cc │ ├── EHM8.cc │ ├── EHM9.cc │ ├── Errno.cc │ ├── Executor.cc │ ├── Fib.cc │ ├── FibPar.cc │ ├── FlexArray.cc │ ├── FloatTest.cc │ ├── Futures.cc │ ├── Futures2.cc │ ├── IO │ │ ├── ClientINETDGRAM.cc │ │ ├── ClientINETSTREAM.cc │ │ ├── ClientINETSTREAMSendfile.cc │ │ ├── ClientUNIXDGRAM.cc │ │ ├── ClientUNIXSTREAM.cc │ │ ├── ClientUNIXSTREAMSendfile.cc │ │ ├── CmdLine.cc │ │ ├── File.cc │ │ ├── Filebuf.cc │ │ ├── Makefile │ │ ├── NBFile.cc │ │ ├── NBStream.cc │ │ ├── Pipes.cc │ │ ├── PipesSelect.cc │ │ ├── ServerINETDGRAM.cc │ │ ├── ServerINETSTREAM.cc │ │ ├── ServerINETSTREAMSendfile.cc │ │ ├── ServerUNIXDGRAM.cc │ │ ├── ServerUNIXSTREAM.cc │ │ ├── ServerUNIXSTREAMSendfile.cc │ │ └── StringIO.cc │ ├── Inheritance.cc │ ├── LOOK.cc │ ├── LockfreeStack.cc │ ├── LockfreeStackPT.cc │ ├── Locks.cc │ ├── LocksFinally.cc │ ├── Makefile │ ├── Matrix.cc │ ├── Merger.cc │ ├── Migrate.cc │ ├── Migrate2.cc │ ├── MonAcceptBB.cc │ ├── MonAcceptReturnBB.cc │ ├── MonConditionBB.cc │ ├── MutexCondBB.cc │ ├── MutexOwner.cc │ ├── Ownership1.cc │ ├── Ownership2.cc │ ├── Ownership3.cc │ ├── Ownership4.cc │ ├── PRNG.cc │ ├── PageRequests │ ├── Paging.cc │ ├── PeriodicTaskTest.cc │ ├── PeriodicTaskTest1.cc │ ├── PeriodicTaskTestStatic.cc │ ├── Processor.cc │ ├── ProdConsDriver.i │ ├── Pthread.cc │ ├── Queue.cc │ ├── RWEx1.cc │ ├── RWEx2.cc │ ├── RWLock.cc │ ├── RWLockPT.cc │ ├── RealTimePhilosophers.cc │ ├── RealTimePhilosophers1.cc │ ├── RealTimePhilosophersStatic.cc │ ├── SRC1.cc │ ├── SRC2.cc │ ├── SRC3.cc │ ├── SRC4.cc │ ├── SemaphoreBB.cc │ ├── Sequence.cc │ ├── Sim.cc │ ├── Sleep.cc │ ├── SpinLock.cc │ ├── Stack.cc │ ├── TaskAcceptBB.cc │ ├── TaskConditionBB.cc │ ├── TimeSlice.cc │ ├── TimeoutAccept.cc │ ├── TimeoutCondLock.cc │ ├── TimeoutPoke.cc │ ├── TimeoutProcessor.cc │ ├── TimeoutPthreadsCond.cc │ ├── TimeoutSem.cc │ ├── UncaughtException.cc │ ├── uCalibrate.cc │ └── uContext.cc │ ├── kernel │ ├── Makefile │ ├── assert.h │ ├── uAbortExit.cc │ ├── uAdaptiveLock.h │ ├── uAlarm.cc │ ├── uAlarm.h │ ├── uAlign.h │ ├── uAtomic.h │ ├── uBaseCoroutine.cc │ ├── uBaseSelector.h │ ├── uBaseTask.cc │ ├── uBootTask.cc │ ├── uBootTask.h │ ├── uC++.cc │ ├── uC++.h │ ├── uCalendar.cc │ ├── uCalendar.h │ ├── uCluster.cc │ ├── uContext.cc │ ├── uDebug.cc │ ├── uDebug.h │ ├── uDefault.h │ ├── uDefaultPreemption.cc │ ├── uDefaultProcessors-OpenMP.cc │ ├── uDefaultProcessors.cc │ ├── uDefaultSpin.cc │ ├── uDefaultStackSize.cc │ ├── uEHM.cc │ ├── uEHM.h │ ├── uFloat.cc │ ├── uHeapLmmm.cc │ ├── uHeapLmmm.h │ ├── uMachContext.cc │ ├── uMainStackSize.cc │ ├── uNBIO.cc │ ├── uProcessor.cc │ ├── uProcessor.h │ ├── uRandom.h │ ├── uReadersWriterLock.h │ ├── uSemaphore.cc │ ├── uSignal.cc │ ├── uStatistics.cc │ ├── uSwitch-arm_64.S │ ├── uSwitch-i386.S │ ├── uSwitch-ia64.S │ ├── uSwitch-m68k.S │ ├── uSwitch-mips.S │ ├── uSwitch-sparc.S │ ├── uSwitch-x86_64.S │ ├── uSystemTask.cc │ ├── uSystemTask.h │ ├── unwind-cxx.h │ ├── unwind.h │ └── write.cc │ ├── library │ ├── Makefile │ ├── Unix.cc │ ├── bits │ │ ├── std_mutex.h │ │ └── unique_lock.h │ ├── fstream.h │ ├── mutex │ ├── ostream.h │ ├── pthread.cc │ ├── semaphore.cc │ ├── shared_mutex │ ├── type_traits │ ├── uActor.cc │ ├── uActor.h │ ├── uBarrier.h │ ├── uCobegin.cc │ ├── uCobegin.h │ ├── uDefaultExecutor.h │ ├── uDefaultExecutorAffinity.cc │ ├── uDefaultExecutorProcessors.cc │ ├── uDefaultExecutorRQueues.cc │ ├── uDefaultExecutorSepClus.cc │ ├── uDefaultExecutorWorkers.cc │ ├── uFile.cc │ ├── uFile.h │ ├── uFilebuf.h │ ├── uFuture.cc │ ├── uFuture.h │ ├── uIOcntl.h │ ├── uPRNG.cc │ ├── uPRNG.h │ ├── uPoll.cc │ ├── uPoll.h │ ├── uRWLock.h │ ├── uSemaphore.h │ ├── uSocket.cc │ ├── uSocket.h │ └── uWaitQueue.h │ ├── profiler │ ├── Makefile │ ├── uProfiler.h │ └── uProfilerFunctionPointers.cc │ ├── scheduler │ ├── Makefile │ ├── uCeilingQ.h │ ├── uDeadlineMonotonic.cc │ ├── uDeadlineMonotonic.h │ ├── uDeadlineMonotonic1.cc │ ├── uDeadlineMonotonic1.h │ ├── uDeadlineMonotonicStatic.cc │ ├── uDeadlineMonotonicStatic.h │ ├── uHeapQ.cc │ ├── uHeapQ.h │ ├── uLifoScheduler.cc │ ├── uLifoScheduler.h │ ├── uPIHeap.cc │ ├── uPIHeap.h │ ├── uRealTime.cc │ ├── uRealTime.h │ ├── uStaticPIQ.cc │ ├── uStaticPIQ.h │ ├── uStaticPriorityQ.cc │ └── uStaticPriorityQ.h │ └── translator │ ├── Makefile │ ├── attribute.cc │ ├── attribute.h │ ├── cc1plus.cc │ ├── debug.h │ ├── gen.cc │ ├── gen.h │ ├── hash.cc │ ├── hash.h │ ├── input.cc │ ├── input.h │ ├── key.cc │ ├── key.h │ ├── main.cc │ ├── main.h │ ├── output.cc │ ├── output.h │ ├── parse.cc │ ├── parse.h │ ├── scan.cc │ ├── scan.h │ ├── structor.cc │ ├── structor.h │ ├── symbol.cc │ ├── symbol.h │ ├── table.cc │ ├── table.h │ ├── token.cc │ ├── token.h │ ├── u++.cc │ └── uassert.h └── u++-7.0.0.sh /source/doc/man/Makefile: -------------------------------------------------------------------------------- 1 | ## Define the appropriate configuration variables. 2 | 3 | PACKAGE = /u0/usystem/software/u++-7.0.0 4 | 5 | ## Include the architecture dependent definitions. 6 | 7 | include ${PACKAGE}/CONFIG 8 | 9 | ## Define the path names of important directories. 10 | 11 | MANDIR = ${PACKAGE}/doc/man 12 | 13 | ## Define some of the tools. 14 | 15 | include ${PACKAGE}/src/MakeTools 16 | 17 | ## Define the text source files. 18 | 19 | MAN = ${addsuffix .1, \ 20 | u++ \ 21 | } 22 | 23 | # Directives # 24 | 25 | all : 26 | 27 | install : ${INSTALLMANDIR} ${INSTALLMANDIR}/man1 ${INSTALLMANDIR}/man1/${MAN}; 28 | 29 | depend : 30 | 31 | clean : 32 | 33 | uninstall : 34 | rm -rf ${INSTALLMANDIR} 35 | 36 | ${INSTALLMANDIR}/man1/${MAN} : ${MANDIR}/${MAN} 37 | ${INSTALL} $< $@ 38 | ${CHMODDATA} $@ 39 | 40 | ## Create directories (TEMPORARY: fixed in gmake 3.80} 41 | 42 | ifeq (${MAKECMDGOALS},install) 43 | _xxx2 := ${shell mkdir -p ${INSTALLMANDIR}/man1} 44 | endif 45 | 46 | ## Local Variables: ## 47 | ## compile-command: "make" ## 48 | ## End: ## 49 | -------------------------------------------------------------------------------- /source/doc/man/README: -------------------------------------------------------------------------------- 1 | There are two troff variables at the beginning of the source files that define 2 | the home path to u++ and the version number. The version variable should be set 3 | properly (we sometimes forget); change the path for the home variable to the 4 | location where u++ is installed. There is a command at the beginning of the 5 | source file to format the manual entry. 6 | -------------------------------------------------------------------------------- /source/doc/refman/DSLNodes.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 11 | 1500 1200 1500 600 600 600 600 1200 1500 1200 12 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 13 | 600 900 1500 900 14 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 15 | 3000 900 3900 900 16 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 17 | 1 1 1.00 45.00 90.00 18 | 1050 750 1800 750 19 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 20 | 1 1 1.00 45.00 90.00 21 | 3450 750 4200 750 22 | 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 23 | 3900 1500 3900 600 3000 600 3000 1500 3900 1500 24 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 25 | 3000 1200 3900 1200 26 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 27 | 1 1 1.00 45.00 90.00 28 | 3450 1050 2700 1050 29 | 4 1 -1 0 0 0 11 0.0000 2 105 255 1050 1125 data\001 30 | 4 1 -1 0 0 0 11 0.0000 2 105 255 3450 1425 data\001 31 | 4 1 -1 0 0 0 11 0.0000 2 105 945 1050 525 collection node\001 32 | 4 1 -1 0 0 0 11 0.0000 2 150 840 3450 525 sequence node\001 33 | -------------------------------------------------------------------------------- /source/doc/refman/DSLNodes.tex: -------------------------------------------------------------------------------- 1 | \setlength{\unitlength}{0.00083333in} 2 | % 3 | \begingroup\makeatletter\ifx\SetFigFont\undefined% 4 | \gdef\SetFigFont#1#2#3#4#5{% 5 | \reset@font\fontsize{#1}{#2pt}% 6 | \fontfamily{#3}\fontseries{#4}\fontshape{#5}% 7 | \selectfont}% 8 | \fi\endgroup% 9 | {\renewcommand{\dashlinestretch}{30} 10 | \begin{picture}(3662,1137)(0,-10) 11 | \path(950,312)(950,912)(50,912) 12 | (50,312)(950,312) 13 | \path(50,612)(950,612) 14 | \path(2450,612)(3350,612) 15 | \path(500,762)(1250,762) 16 | \blacken\path(1160.000,739.500)(1250.000,762.000)(1160.000,784.500)(1160.000,739.500) 17 | \path(2900,762)(3650,762) 18 | \blacken\path(3560.000,739.500)(3650.000,762.000)(3560.000,784.500)(3560.000,739.500) 19 | \path(3350,12)(3350,912)(2450,912) 20 | (2450,12)(3350,12) 21 | \path(2450,312)(3350,312) 22 | \path(2900,462)(2150,462) 23 | \blacken\path(2240.000,484.500)(2150.000,462.000)(2240.000,439.500)(2240.000,484.500) 24 | \put(500,387){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}data}}}} 25 | \put(2900,87){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}data}}}} 26 | \put(500,987){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}collection node}}}} 27 | \put(2900,987){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}sequence node}}}} 28 | \end{picture} 29 | } 30 | -------------------------------------------------------------------------------- /source/doc/refman/DSLQueue.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 3675 675 3825 825 11 | 4 1 -1 0 0 0 11 0.0000 2 105 75 3750 825 0\001 12 | 4 1 -1 0 0 0 11 0.0000 2 105 45 3750 825 /\001 13 | -6 14 | 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 15 | 1800 1200 1800 600 900 600 900 1200 1800 1200 16 | 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 17 | 3000 1200 3000 600 2100 600 2100 1200 3000 1200 18 | 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 19 | 4200 1200 4200 600 3300 600 3300 1200 4200 1200 20 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 21 | 900 900 1800 900 22 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 23 | 2100 900 3000 900 24 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 25 | 3300 900 4200 900 26 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 27 | 0 0 1.00 45.00 90.00 28 | 1350 750 2100 750 29 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 30 | 0 0 1.00 45.00 90.00 31 | 2550 750 3300 750 32 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 33 | 0 0 1.00 45.00 90.00 34 | 450 750 900 750 35 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 36 | 0 0 1.00 45.00 90.00 37 | 4650 750 4200 750 38 | 4 1 -1 0 0 0 11 0.0000 2 105 255 1350 1125 data\001 39 | 4 1 -1 0 0 0 11 0.0000 2 105 255 2550 1125 data\001 40 | 4 1 -1 0 0 0 11 0.0000 2 105 255 3750 1125 data\001 41 | 4 1 -1 0 0 0 11 0.0000 2 120 345 2550 525 queue\001 42 | 4 0 -1 0 0 0 11 0.0000 2 105 225 4725 825 tail\001 43 | 4 2 -1 0 0 0 11 0.0000 2 105 270 375 825 head\001 44 | -------------------------------------------------------------------------------- /source/doc/refman/DSLQueue.tex: -------------------------------------------------------------------------------- 1 | \setlength{\unitlength}{0.00083333in} 2 | % 3 | \begingroup\makeatletter\ifx\SetFigFont\undefined% 4 | \gdef\SetFigFont#1#2#3#4#5{% 5 | \reset@font\fontsize{#1}{#2pt}% 6 | \fontfamily{#3}\fontseries{#4}\fontshape{#5}% 7 | \selectfont}% 8 | \fi\endgroup% 9 | {\renewcommand{\dashlinestretch}{30} 10 | \begin{picture}(4887,813)(0,-10) 11 | \path(1717,12)(1717,612)(817,612) 12 | (817,12)(1717,12) 13 | \path(2917,12)(2917,612)(2017,612) 14 | (2017,12)(2917,12) 15 | \path(4117,12)(4117,612)(3217,612) 16 | (3217,12)(4117,12) 17 | \path(817,312)(1717,312) 18 | \path(2017,312)(2917,312) 19 | \path(3217,312)(4117,312) 20 | \path(1267,462)(2017,462) 21 | \path(1927.000,439.500)(2017.000,462.000)(1927.000,484.500) 22 | \path(2467,462)(3217,462) 23 | \path(3127.000,439.500)(3217.000,462.000)(3127.000,484.500) 24 | \path(367,462)(817,462) 25 | \path(727.000,439.500)(817.000,462.000)(727.000,484.500) 26 | \path(4567,462)(4117,462) 27 | \path(4207.000,484.500)(4117.000,462.000)(4207.000,439.500) 28 | \put(3667,387){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}0}}}} 29 | \put(3667,387){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}/}}}} 30 | \put(1267,87){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}data}}}} 31 | \put(2467,87){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}data}}}} 32 | \put(3667,87){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}data}}}} 33 | \put(2467,687){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}queue}}}} 34 | \put(4642,387){\makebox(0,0)[lb]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}tail}}}} 35 | \put(292,387){\makebox(0,0)[rb]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}head}}}} 36 | \end{picture} 37 | } 38 | -------------------------------------------------------------------------------- /source/doc/refman/DSLSequence.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 3675 675 3825 825 11 | 4 1 -1 0 0 0 11 0.0000 2 105 75 3750 825 0\001 12 | 4 1 -1 0 0 0 11 0.0000 2 105 45 3750 825 /\001 13 | -6 14 | 6 1275 975 1425 1125 15 | 4 1 -1 0 0 0 11 0.0000 2 105 75 1350 1125 0\001 16 | 4 1 -1 0 0 0 11 0.0000 2 105 45 1350 1125 /\001 17 | -6 18 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 19 | 900 900 1800 900 20 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 21 | 2100 900 3000 900 22 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 23 | 3300 900 4200 900 24 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 25 | 1 1 1.00 45.00 90.00 26 | 1350 750 2100 750 27 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 28 | 1 1 1.00 45.00 90.00 29 | 2550 750 3300 750 30 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 31 | 1 1 1.00 45.00 90.00 32 | 450 750 900 750 33 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 34 | 1 1 1.00 45.00 90.00 35 | 4650 750 4200 750 36 | 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 37 | 1800 1500 1800 600 900 600 900 1500 1800 1500 38 | 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 39 | 3000 1500 3000 600 2100 600 2100 1500 3000 1500 40 | 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 41 | 4200 1500 4200 600 3300 600 3300 1500 4200 1500 42 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 43 | 900 1200 1800 1200 44 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 45 | 2100 1200 3000 1200 46 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 47 | 3300 1200 4200 1200 48 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 49 | 1 1 1.00 45.00 90.00 50 | 3750 1050 3000 1050 51 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 52 | 1 1 1.00 45.00 90.00 53 | 2550 1050 1800 1050 54 | 4 0 -1 0 0 0 11 0.0000 2 105 225 4725 825 tail\001 55 | 4 2 -1 0 0 0 11 0.0000 2 105 270 375 825 head\001 56 | 4 1 -1 0 0 0 11 0.0000 2 105 255 1350 1425 data\001 57 | 4 1 -1 0 0 0 11 0.0000 2 105 255 2550 1425 data\001 58 | 4 1 -1 0 0 0 11 0.0000 2 105 255 3750 1425 data\001 59 | 4 1 -1 0 0 0 11 0.0000 2 120 525 2550 525 sequence\001 60 | -------------------------------------------------------------------------------- /source/doc/refman/DSLSequence.tex: -------------------------------------------------------------------------------- 1 | \setlength{\unitlength}{0.00083333in} 2 | % 3 | \begingroup\makeatletter\ifx\SetFigFont\undefined% 4 | \gdef\SetFigFont#1#2#3#4#5{% 5 | \reset@font\fontsize{#1}{#2pt}% 6 | \fontfamily{#3}\fontseries{#4}\fontshape{#5}% 7 | \selectfont}% 8 | \fi\endgroup% 9 | {\renewcommand{\dashlinestretch}{30} 10 | \begin{picture}(4887,1113)(0,-10) 11 | \path(817,612)(1717,612) 12 | \path(2017,612)(2917,612) 13 | \path(3217,612)(4117,612) 14 | \path(1267,762)(2017,762) 15 | \blacken\path(1927.000,739.500)(2017.000,762.000)(1927.000,784.500)(1927.000,739.500) 16 | \path(2467,762)(3217,762) 17 | \blacken\path(3127.000,739.500)(3217.000,762.000)(3127.000,784.500)(3127.000,739.500) 18 | \path(367,762)(817,762) 19 | \blacken\path(727.000,739.500)(817.000,762.000)(727.000,784.500)(727.000,739.500) 20 | \path(4567,762)(4117,762) 21 | \blacken\path(4207.000,784.500)(4117.000,762.000)(4207.000,739.500)(4207.000,784.500) 22 | \path(1717,12)(1717,912)(817,912) 23 | (817,12)(1717,12) 24 | \path(2917,12)(2917,912)(2017,912) 25 | (2017,12)(2917,12) 26 | \path(4117,12)(4117,912)(3217,912) 27 | (3217,12)(4117,12) 28 | \path(817,312)(1717,312) 29 | \path(2017,312)(2917,312) 30 | \path(3217,312)(4117,312) 31 | \path(3667,462)(2917,462) 32 | \blacken\path(3007.000,484.500)(2917.000,462.000)(3007.000,439.500)(3007.000,484.500) 33 | \path(2467,462)(1717,462) 34 | \blacken\path(1807.000,484.500)(1717.000,462.000)(1807.000,439.500)(1807.000,484.500) 35 | \put(3667,687){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}0}}}} 36 | \put(3667,687){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}/}}}} 37 | \put(1267,387){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}0}}}} 38 | \put(1267,387){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}/}}}} 39 | \put(4642,687){\makebox(0,0)[lb]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}tail}}}} 40 | \put(292,687){\makebox(0,0)[rb]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}head}}}} 41 | \put(1267,87){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}data}}}} 42 | \put(2467,87){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}data}}}} 43 | \put(3667,87){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}data}}}} 44 | \put(2467,987){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}sequence}}}} 45 | \end{picture} 46 | } 47 | -------------------------------------------------------------------------------- /source/doc/refman/DSLStack.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 3675 675 3825 825 11 | 4 1 -1 0 0 0 11 0.0000 2 105 45 3750 825 /\001 12 | 4 1 -1 0 0 0 11 0.0000 2 105 75 3750 825 0\001 13 | -6 14 | 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 15 | 1800 1200 1800 600 900 600 900 1200 1800 1200 16 | 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 17 | 3000 1200 3000 600 2100 600 2100 1200 3000 1200 18 | 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 19 | 4200 1200 4200 600 3300 600 3300 1200 4200 1200 20 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 21 | 900 900 1800 900 22 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 23 | 2100 900 3000 900 24 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 0 0 2 25 | 3300 900 4200 900 26 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 27 | 1 1 1.00 45.00 90.00 28 | 1350 750 2100 750 29 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 30 | 1 1 1.00 45.00 90.00 31 | 2550 750 3300 750 32 | 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 33 | 1 1 1.00 45.00 90.00 34 | 450 750 900 750 35 | 4 1 -1 0 0 0 11 0.0000 2 105 255 1350 1125 data\001 36 | 4 1 -1 0 0 0 11 0.0000 2 105 255 2550 1125 data\001 37 | 4 1 -1 0 0 0 11 0.0000 2 105 255 3750 1125 data\001 38 | 4 2 -1 0 0 0 11 0.0000 2 135 210 375 825 top\001 39 | 4 1 -1 0 0 0 11 0.0000 2 105 315 2550 525 stack\001 40 | -------------------------------------------------------------------------------- /source/doc/refman/DSLStack.tex: -------------------------------------------------------------------------------- 1 | \setlength{\unitlength}{0.00083333in} 2 | % 3 | \begingroup\makeatletter\ifx\SetFigFont\undefined% 4 | \gdef\SetFigFont#1#2#3#4#5{% 5 | \reset@font\fontsize{#1}{#2pt}% 6 | \fontfamily{#3}\fontseries{#4}\fontshape{#5}% 7 | \selectfont}% 8 | \fi\endgroup% 9 | {\renewcommand{\dashlinestretch}{30} 10 | \begin{picture}(4068,822)(0,-10) 11 | \path(1656,12)(1656,612)(756,612) 12 | (756,12)(1656,12) 13 | \path(2856,12)(2856,612)(1956,612) 14 | (1956,12)(2856,12) 15 | \path(4056,12)(4056,612)(3156,612) 16 | (3156,12)(4056,12) 17 | \path(756,312)(1656,312) 18 | \path(1956,312)(2856,312) 19 | \path(3156,312)(4056,312) 20 | \path(1206,462)(1956,462) 21 | \blacken\path(1866.000,439.500)(1956.000,462.000)(1866.000,484.500)(1866.000,439.500) 22 | \path(2406,462)(3156,462) 23 | \blacken\path(3066.000,439.500)(3156.000,462.000)(3066.000,484.500)(3066.000,439.500) 24 | \path(306,462)(756,462) 25 | \blacken\path(666.000,439.500)(756.000,462.000)(666.000,484.500)(666.000,439.500) 26 | \put(3606,387){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}/}}}} 27 | \put(3606,387){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}0}}}} 28 | \put(1206,87){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}data}}}} 29 | \put(2406,87){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}data}}}} 30 | \put(3606,87){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}data}}}} 31 | \put(231,387){\makebox(0,0)[rb]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}top}}}} 32 | \put(2406,687){\makebox(0,0)[b]{\smash{{\SetFigFont{11}{13.2}{\familydefault}{\mddefault}{\updefault}stack}}}} 33 | \end{picture} 34 | } 35 | -------------------------------------------------------------------------------- /source/doc/refman/DirectComm.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 1950 900 45 45 1950 900 1995 945 11 | 2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 3 12 | 1 1 1.00 45.00 90.00 13 | 900 675 901 901 1950 900 14 | 2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 15 | 1 1 1.00 45.00 90.00 16 | 1950 976 1950 1575 17 | 2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 3 18 | 1 1 1.00 45.00 90.00 19 | 3000 675 3000 900 1951 899 20 | 2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 3 21 | 1 1 1.00 45.00 90.00 22 | 1951 1574 3000 1575 3000 1875 23 | 2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 1 0 3 24 | 1 1 1.00 45.00 90.00 25 | 1949 1574 900 1575 900 1875 26 | 4 1 -1 0 0 0 12 0.0000 2 195 735 901 601 Task$_1$\001 27 | 4 1 -1 0 0 0 12 0.0000 2 195 735 3001 601 Task$_2$\001 28 | 4 0 -1 0 0 0 12 0.0000 2 135 870 2101 1276 rendezvous\001 29 | -------------------------------------------------------------------------------- /source/doc/refman/DirectComm.tex: -------------------------------------------------------------------------------- 1 | \setlength{\unitlength}{0.00083333in} 2 | % 3 | \begingroup\makeatletter\ifx\SetFigFont\undefined% 4 | \gdef\SetFigFont#1#2#3#4#5{% 5 | \reset@font\fontsize{#1}{#2pt}% 6 | \fontfamily{#3}\fontseries{#4}\fontshape{#5}% 7 | \selectfont}% 8 | \fi\endgroup% 9 | {\renewcommand{\dashlinestretch}{30} 10 | \begin{picture}(2189,1482)(0,-10) 11 | \put(1094,997){\blacken\ellipse{90}{90}} 12 | \put(1094,997){\ellipse{90}{90}} 13 | \thicklines 14 | \path(44,1222)(45,996)(1094,997) 15 | \blacken\thinlines 16 | \path(1004.021,974.414)(1094.000,997.000)(1003.979,1019.414)(1004.021,974.414) 17 | \thicklines 18 | \path(1094,921)(1094,322) 19 | \blacken\thinlines 20 | \path(1071.500,412.000)(1094.000,322.000)(1116.500,412.000)(1071.500,412.000) 21 | \thicklines 22 | \path(2144,1222)(2144,997)(1095,998) 23 | \blacken\thinlines 24 | \path(1185.021,1020.414)(1095.000,998.000)(1184.979,975.414)(1185.021,1020.414) 25 | \thicklines 26 | \path(1095,323)(2144,322)(2144,22) 27 | \blacken\thinlines 28 | \path(2121.500,112.000)(2144.000,22.000)(2166.500,112.000)(2121.500,112.000) 29 | \thicklines 30 | \path(1093,323)(44,322)(44,22) 31 | \blacken\thinlines 32 | \path(21.500,112.000)(44.000,22.000)(66.500,112.000)(21.500,112.000) 33 | \put(45,1296){\makebox(0,0)[b]{\smash{{\SetFigFont{12}{14.4}{\familydefault}{\mddefault}{\updefault}Task$_1$}}}} 34 | \put(2145,1296){\makebox(0,0)[b]{\smash{{\SetFigFont{12}{14.4}{\familydefault}{\mddefault}{\updefault}Task$_2$}}}} 35 | \put(1245,621){\makebox(0,0)[lb]{\smash{{\SetFigFont{12}{14.4}{\familydefault}{\mddefault}{\updefault}rendezvous}}}} 36 | \end{picture} 37 | } 38 | -------------------------------------------------------------------------------- /source/doc/refman/README: -------------------------------------------------------------------------------- 1 | 2 | To build the reference manual for uC++ type "gmake" in this directory. This 3 | constructs a postscript ".ps" file that can be printed. 4 | -------------------------------------------------------------------------------- /source/doc/refman/TraceMsg.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 Produced by xfig version 3.2.7b 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 11 | 1200 1800 1800 1800 1800 2100 1200 2100 1200 1800 12 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 13 | 3600 1800 4200 1800 4200 2100 3600 2100 3600 1800 14 | 2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 1 0 2 15 | 1 1 1.00 45.00 90.00 16 | 1800 1875 2400 1875 17 | 2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 1 0 2 18 | 1 1 1.00 45.00 90.00 19 | 3000 1875 3600 1875 20 | 2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 1 0 2 21 | 1 1 1.00 45.00 90.00 22 | 4200 1875 4800 1875 23 | 2 1 1 1 4 7 50 -1 -1 4.000 0 0 -1 1 0 2 24 | 1 1 1.00 45.00 90.00 25 | 4800 2025 4200 2025 26 | 2 1 1 1 4 7 50 -1 -1 4.000 0 0 -1 1 0 2 27 | 1 1 1.00 45.00 90.00 28 | 3600 2025 3000 2025 29 | 2 1 1 1 4 7 50 -1 -1 4.000 0 0 -1 1 0 2 30 | 1 1 1.00 45.00 90.00 31 | 2400 2025 1800 2025 32 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 33 | 1 1 1.00 45.00 90.00 34 | 1500 2325 1500 2100 35 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 36 | 1 1 1.00 45.00 90.00 37 | 3900 2325 3900 2100 38 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 39 | 2400 1800 3000 1800 3000 2100 2400 2100 2400 1800 40 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 41 | 4800 1800 5400 1800 5400 2100 4800 2100 4800 1800 42 | 2 1 0 1 0 7 50 -1 -1 4.000 0 0 -1 1 0 2 43 | 1 1 1.00 45.00 90.00 44 | 5400 1875 6000 1875 45 | 2 1 1 1 4 7 50 -1 -1 4.000 0 0 -1 1 0 2 46 | 1 1 1.00 45.00 90.00 47 | 6000 2025 5400 2025 48 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 49 | 6000 1800 6600 1800 6600 2100 6000 2100 6000 1800 50 | 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 51 | 1 1 1.00 45.00 90.00 52 | 6300 2325 6300 2100 53 | 4 1 0 50 -1 0 10 0.0000 2 120 225 1500 1725 A1\001 54 | 4 1 0 50 -1 0 10 0.0000 2 120 225 3900 1725 A3\001 55 | 4 1 0 50 -1 0 10 0.0000 2 75 135 2100 1800 m\001 56 | 4 1 0 50 -1 0 10 0.0000 2 75 135 3300 1800 m\001 57 | 4 2 0 50 -1 0 10 0.0000 2 165 345 1125 2100 hops\001 58 | 4 2 0 50 -1 0 10 0.0000 2 120 405 1125 1950 sends\001 59 | 4 1 0 50 -1 0 10 0.0000 2 75 135 4500 1800 m\001 60 | 4 1 0 50 -1 0 10 0.0000 2 120 210 1500 2475 tail\001 61 | 4 1 4 50 -1 0 10 0.0000 2 180 2385 3900 2475 $\\leftarrow$ cursor $\\rightarrow$\001 62 | 4 1 0 50 -1 0 10 0.0000 2 120 225 2700 1725 A2\001 63 | 4 1 0 50 -1 0 10 0.0000 2 120 225 5100 1725 A4\001 64 | 4 1 0 50 -1 0 10 0.0000 2 120 225 6300 1725 A5\001 65 | 4 1 0 50 -1 0 10 0.0000 2 120 330 6300 2475 head\001 66 | 4 1 0 50 -1 0 10 0.0000 2 75 135 5700 1800 m\001 67 | -------------------------------------------------------------------------------- /source/doc/refman/TraceMsg.pstex_t: -------------------------------------------------------------------------------- 1 | \begin{picture}(0,0)% 2 | \includegraphics{TraceMsg.pstex}% 3 | \end{picture}% 4 | \setlength{\unitlength}{3947sp}% 5 | % 6 | \begingroup\makeatletter\ifx\SetFigFont\undefined% 7 | \gdef\SetFigFont#1#2#3#4#5{% 8 | \reset@font\fontsize{#1}{#2pt}% 9 | \fontfamily{#3}\fontseries{#4}\fontshape{#5}% 10 | \selectfont}% 11 | \fi\endgroup% 12 | \begin{picture}(5918,954)(695,-1705) 13 | \put(1501,-886){\makebox(0,0)[b]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}A1}% 14 | }}}} 15 | \put(3901,-886){\makebox(0,0)[b]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}A3}% 16 | }}}} 17 | \put(2101,-961){\makebox(0,0)[b]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}m}% 18 | }}}} 19 | \put(3301,-961){\makebox(0,0)[b]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}m}% 20 | }}}} 21 | \put(1126,-1261){\makebox(0,0)[rb]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}hops}% 22 | }}}} 23 | \put(1126,-1111){\makebox(0,0)[rb]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}sends}% 24 | }}}} 25 | \put(4501,-961){\makebox(0,0)[b]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}m}% 26 | }}}} 27 | \put(1501,-1636){\makebox(0,0)[b]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}tail}% 28 | }}}} 29 | \put(3901,-1636){\makebox(0,0)[b]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{1,0,0}$\leftarrow$ cursor $\rightarrow$}% 30 | }}}} 31 | \put(2701,-886){\makebox(0,0)[b]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}A2}% 32 | }}}} 33 | \put(5101,-886){\makebox(0,0)[b]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}A4}% 34 | }}}} 35 | \put(6301,-886){\makebox(0,0)[b]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}A5}% 36 | }}}} 37 | \put(6301,-1636){\makebox(0,0)[b]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}head}% 38 | }}}} 39 | \put(5701,-961){\makebox(0,0)[b]{\smash{{\SetFigFont{10}{12.0}{\familydefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}m}% 40 | }}}} 41 | \end{picture}% 42 | -------------------------------------------------------------------------------- /source/gdb/.gdbinit: -------------------------------------------------------------------------------- 1 | # These signal are necessary for uC++, so tell gdb to ignore them 2 | # and pass to through to the program. 3 | handle SIGALRM nostop noprint pass 4 | handle SIGUSR1 nostop noprint pass 5 | # Load macros to make gdb understand uC++ user-threads 6 | source /usr/local/u++-7.0.0/gdb/utils-gdb.py 7 | source /usr/local/u++-7.0.0/gdb/utils-gdb.gdb 8 | # Have gdb indent complex values to make them readable. 9 | set print pretty 10 | -------------------------------------------------------------------------------- /source/gdb/README: -------------------------------------------------------------------------------- 1 | These instructions assume the install for uC++ is /usr/local/u++-7.0.0. 2 | If installed elsewhere, change . 3 | 4 | Copy /.gdbinit to your home directory. If installed elsewhere, change 5 | the within .gdbinit. Thereafter, gdb automatically loads the .gdbinit 6 | file from the home directory making the following new gdb commands available. 7 | 8 | New commands: 9 | 10 | info clusters : print list of clusters 11 | info vprocessors : print virtual processors in userCluster 12 | info vprocessors : print virtual processors in cluster 13 | task : print tasks (ids) in userCluster, application tasks only 14 | task : print tasks (ids) in clusterName, application tasks only 15 | task all : print all clusters, all tasks 16 | task : switch debugging stack to task id on userCluster 17 | task 0x
: switch debugging stack to task 0x
on any cluster 18 | task : switch debugging stack to task id on cluster clusterName 19 | 20 | -------------------------------------------------------------------------------- /source/gdb/utils-gdb.gdb: -------------------------------------------------------------------------------- 1 | # 'server' keyword disables confirmation dialog when re-loading/re-defining 2 | # 'reset' restores the registers to the stack values at breakpoint to allow the movement commands to work correctly 3 | server define hook-continue 4 | reset 5 | end 6 | 7 | server define hook-next 8 | reset 9 | end 10 | 11 | server define hook-nexti 12 | reset 13 | end 14 | 15 | server define hook-step 16 | reset 17 | end 18 | 19 | server define hook-stepi 20 | reset 21 | end 22 | 23 | server define hook-finish 24 | reset 25 | end 26 | 27 | server define hook-advance 28 | reset 29 | end 30 | 31 | server define hook-jump 32 | reset 33 | end 34 | 35 | server define hook-signal 36 | reset 37 | end 38 | 39 | server define hook-until 40 | reset 41 | end 42 | 43 | server define hook-reverse-next 44 | reset 45 | end 46 | 47 | server define hook-reverse-step 48 | reset 49 | end 50 | 51 | server define hook-reverse-stepi 52 | reset 53 | end 54 | 55 | server define hook-reverse-continue 56 | reset 57 | end 58 | 59 | server define hook-reverse-finish 60 | reset 61 | end 62 | 63 | server define hook-run 64 | reset 65 | end 66 | 67 | server define hook-thread 68 | reset 69 | end 70 | 71 | alias -a clusters = info clusters 72 | alias -a vprocessors = info vprocessors 73 | -------------------------------------------------------------------------------- /source/src/MakeTools: -------------------------------------------------------------------------------- 1 | ## Define some of the tools that are used by the make process. 2 | 3 | # The u++ translator is used to build the kernel and library support code to allow uC++ keywords, like _Coroutine, 4 | # _Task, _Mutex, etc. However, the translator does not need to make available the uC++ includes during kernel build 5 | # because the include directory (inc) is being created, so these directories and special includes are turned off using 6 | # flag "-no-u++-include". 7 | 8 | CC = ${PACKAGE}/src/translator/bin-${OS}-${CPU}/${UPP} 9 | 10 | CCFLAGS = -std=c++17 -B${PACKAGE}/src/translator/lib-${OS}-${CPU} -I. -I${PACKAGE}/src/collection -I${PACKAGE}/src/kernel -I${PACKAGE}/src/scheduler -I${PACKAGE}/src/library -I${PACKAGE}/src/debugger -I${PACKAGE}/src/profiler -DPACKAGE=\"${PACKAGE}\" -DVERSION=\"${VERSION}\" -DTMPDIR=\"${TMPDIR}\" -no-u++-include 11 | 12 | ifeq (${TCPU} ${TCPU}, i386 x86_64) 13 | CCFLAGS += -m${WORDSIZE} 14 | endif 15 | 16 | #CCFLAGS += -D__U_PROFILER__ 17 | #CCFLAGS += -profile -D__U_PROFILEABLE_ONLY__ 18 | 19 | #CCFLAGS += -I/home/pabuhr/include/x86_64-linux -DKNOT -DBIGGER_FD_SETSIZE2 # -DBIGGER_FD_SETSIZE uKnot/Linux 20 | #CCFLAGS += -DFD_SETSIZE=65536 -DKNOT # uKnot 21 | 22 | HOSTNAME = ${shell hostname} 23 | ifeq (${HOSTNAME},plg2) # development machine 24 | # When -O2/3 is specified, compilers can generate additional warning messages. 25 | CCFLAGS += -Wall -Wextra -g -O3 # 26 | else 27 | CCFLAGS += -Wall -Wextra -g -O3 # 28 | endif 29 | 30 | AR = ar cr 31 | 32 | RL = ${shell if [ -f /usr/bin/ranlib -o -f /bin/ranlib ]; then echo "ranlib"; else echo "echo"; fi} 33 | 34 | RM = rm -rf 35 | 36 | INSTALL = cp 37 | CHMODEXEC = chmod 0755 38 | CHMODDATA = chmod 0644 39 | -------------------------------------------------------------------------------- /source/src/collection/Makefile: -------------------------------------------------------------------------------- 1 | ## Define the appropriate configuration variables. 2 | 3 | PACKAGE = /u0/usystem/software/u++-7.0.0 4 | 5 | ## Include the architecture dependent definitions. 6 | 7 | include ${PACKAGE}/CONFIG 8 | 9 | ## Define the path names of important directories. 10 | 11 | SRCDIR = ${PACKAGE}/src/collection 12 | 13 | ## Define some of the tools. 14 | 15 | include ${PACKAGE}/src/MakeTools 16 | 17 | ## Define the header files 18 | 19 | HEADERS = ${shell ls *.h} 20 | 21 | ## Define the things that can be defined based upon previous definitions. 22 | 23 | include ${PACKAGE}/src/MakeDefinitions 24 | 25 | ## Define the specific recipes. 26 | 27 | all : 28 | 29 | INSTALLFILES = ${addprefix ${INSTALLINCDIR}/, ${HEADERS}} 30 | 31 | install : all ${INSTALLFILES} 32 | 33 | CLEAN = 34 | 35 | ## Define default dependencies and recipes for object files. 36 | 37 | include ${PACKAGE}/src/MakeRecipes 38 | 39 | ## Create directories (TEMPORARY: fixed in gmake 3.80) 40 | 41 | ifeq (${MAKECMDGOALS},install) 42 | _xxx2 := ${shell mkdir -p ${INSTALLINCDIR}} 43 | endif 44 | 45 | ## Local Variables: ## 46 | ## compile-command: "make install" ## 47 | ## End: ## 48 | -------------------------------------------------------------------------------- /source/src/debugger/Makefile: -------------------------------------------------------------------------------- 1 | ## Define the appropriate configuration variables. 2 | 3 | PACKAGE = /u0/usystem/software/u++-7.0.0 4 | 5 | ## Include the architecture dependent definitions. 6 | 7 | include ${PACKAGE}/CONFIG 8 | 9 | ## Define the path names of important directories. 10 | 11 | SRCDIR = ${PACKAGE}/src/debugger 12 | 13 | ## Define some of the tools. 14 | 15 | include ${PACKAGE}/src/MakeTools 16 | 17 | ## Define the C++ source files. 18 | 19 | LIBSRC = ${addprefix ${SRCDIR}/, ${addsuffix .cc, \ 20 | uBConditionEval \ 21 | uDebuggerProtocolUnit \ 22 | uLocalDebugger \ 23 | } } 24 | 25 | LIBSRC-D = ${LIBSRC} 26 | ifeq (${MULTI},TRUE) 27 | # LIBSRC-M = ${LIBSRC} 28 | LIBSRC-M-D = ${LIBSRC} 29 | endif 30 | 31 | ## Define the header files 32 | 33 | HEADERS = uLocalDebugger.h uDebuggerAPI.h 34 | 35 | ## Define which libraries should be built. 36 | 37 | #LIB = ${LIBDIR}/uLocalDebugger.a 38 | LIB-D = ${LIBDIR}/uLocalDebugger-d.a 39 | ifeq (${MULTI},TRUE) 40 | # LIB-M = ${LIBDIR}/uLocalDebugger-m.a 41 | LIB-M-D = ${LIBDIR}/uLocalDebugger-m-d.a 42 | endif 43 | 44 | ## Define the things that can be defined based upon previous definitions. 45 | 46 | include ${PACKAGE}/src/MakeDefinitions 47 | 48 | ## Define specific flags 49 | 50 | SIZE_OF_BREAKPOINT_FIELD := 64 51 | 52 | CCFLAGS += -DSIZE_OF_BREAKPOINT_FIELD=${SIZE_OF_BREAKPOINT_FIELD} #-DDEBUG_ON 53 | 54 | CLEAN += ${SRCDIR}/uLocalDebuggerHandler.h 55 | 56 | ## Define the specific recipes. 57 | 58 | all : ${LIBRARIES} 59 | 60 | INSTALLFILES = ${addprefix ${INSTALLLIBDIR}/, ${notdir ${LIBRARIES}}} ${addprefix ${INSTALLINCDIR}/, ${HEADERS}} 61 | 62 | install : all ${INSTALLFILES} 63 | 64 | ## Define special rules for making the break point header file. 65 | 66 | uLocalDebuggerHandler.h : ${SRCDIR}/uMakeBPstubs-${TCPU} 67 | ${SRCDIR}/uMakeBPstubs-${TCPU} ${SIZE_OF_BREAKPOINT_FIELD} > $@ 68 | 69 | ## Define default dependencies and recipes for object files. 70 | 71 | include ${PACKAGE}/src/MakeRecipes 72 | 73 | ## Include the dependencies for object files and libraries. 74 | 75 | ${OBJDIR}/uLocalDebugger.o ${OBJDIR}/uLocalDebugger-d.o ${OBJDIR}/uLocalDebugger-m.o ${OBJDIR}/uLocalDebugger-m-d.o : uLocalDebuggerHandler.h 76 | -include ${DEPENDS} 77 | 78 | ## Create directories (TEMPORARY: fixed in gmake 3.80) 79 | 80 | _xxx1 := ${shell mkdir -p ${LIBDIR} ${OBJDIR}} 81 | 82 | ifeq (${MAKECMDGOALS},install) 83 | _xxx2 := ${shell mkdir -p ${INSTALLLIBDIR} ${INSTALLINCDIR}} 84 | endif 85 | 86 | ## Local Variables: ## 87 | ## compile-command: "make install" ## 88 | ## End: ## 89 | -------------------------------------------------------------------------------- /source/src/debugger/uBConditionEval.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Jun Shih 1995 4 | // 5 | // uBConditionEval.h -- 6 | // 7 | // Author : Jun Shih 8 | // Created On : Sat Nov 11 14:44:08 EST 1995 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Tue Apr 5 08:04:41 2022 11 | // Update Count : 22 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #ifndef _uBConditionEval_h_ 28 | #define _uBConditionEval_h_ 29 | #include 30 | 31 | 32 | class uBConditionEval : public uSeqable { 33 | friend _Task uLocalDebugger; 34 | struct BreakpointCondition bp_cond; 35 | ULThreadId ul_thread_id; 36 | 37 | int eval_int( int which ); 38 | 39 | CodeAddress eval_address_local( int which ); 40 | CodeAddress eval_address_static( int which ); 41 | CodeAddress eval_address_const( int which ); 42 | CodeAddress eval_address_register( int which ); 43 | public: 44 | uBConditionEval( ULThreadId ul_thread_id ); 45 | ~uBConditionEval(); 46 | void setId( ULThreadId Id ); 47 | ULThreadId getId(); 48 | void setFp ( long fp_val ); 49 | void setSp ( long sp_val ); 50 | long getFp(); 51 | long getSp(); 52 | BreakpointCondition::OperationType getOperator(); 53 | BreakpointCondition& getBp_cond(); 54 | int evaluate(); 55 | }; // uBConditionEval 56 | 57 | 58 | // This class is necessary to avoid circular #include's 59 | class uBConditionList { 60 | uSequence bp_list; 61 | public: 62 | uBConditionList(); 63 | ~uBConditionList(); 64 | uBConditionEval *search( ULThreadId ul_thread_id ); 65 | void add( uBConditionEval* bc_eval ); 66 | bool del( ULThreadId ul_thread_id ); 67 | }; // uBConditionList 68 | 69 | 70 | #endif // _uBConditionEval_h_ 71 | 72 | 73 | // Local Variables: // 74 | // compile-command: "make install" // 75 | // End: // 76 | -------------------------------------------------------------------------------- /source/src/debugger/uMakeBPstubs-alpha: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "//###################### uLocalDebuggerHandler #########################" 3 | echo "// generated automatically => do not change !" 4 | echo 5 | echo "class uLocalDebuggerHandler {" 6 | echo "public:" 7 | echo " uLocalDebuggerHandler() {}" 8 | echo "};" 9 | -------------------------------------------------------------------------------- /source/src/debugger/uMakeBPstubs-arm_64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "//###################### uLocalDebuggerHandler #########################" 3 | echo "// generated automatically => do not change !" 4 | echo 5 | echo "class uLocalDebuggerHandler {" 6 | echo "public:" 7 | echo " uLocalDebuggerHandler() {}" 8 | echo "};" 9 | -------------------------------------------------------------------------------- /source/src/debugger/uMakeBPstubs-hppa: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "//###################### uLocalDebuggerHandler #########################" 3 | echo "// generated automatically => do not change !" 4 | echo 5 | echo "class uLocalDebuggerHandler {" 6 | echo "public:" 7 | echo " uLocalDebuggerHandler() {}" 8 | echo "};" 9 | -------------------------------------------------------------------------------- /source/src/debugger/uMakeBPstubs-ia64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "//###################### uLocalDebuggerHandler #########################" 3 | echo "// generated automatically => do not change !" 4 | echo 5 | echo "class uLocalDebuggerHandler {" 6 | echo "public:" 7 | echo " uLocalDebuggerHandler() {}" 8 | echo "};" 9 | -------------------------------------------------------------------------------- /source/src/debugger/uMakeBPstubs-m68k: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "//###################### uLocalDebuggerHandler #########################" 3 | echo "// generated automatically => do not change !" 4 | echo 5 | echo "class uLocalDebuggerHandler {" 6 | echo "public:" 7 | echo " uLocalDebuggerHandler() {}" 8 | echo "};" 9 | -------------------------------------------------------------------------------- /source/src/debugger/uMakeBPstubs-mips: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "//###################### uLocalDebuggerHandler #########################" 3 | echo "// generated automatically => do not change !" 4 | echo 5 | echo "class uLocalDebuggerHandler {" 6 | echo "public:" 7 | echo " uLocalDebuggerHandler() {}" 8 | echo "};" 9 | -------------------------------------------------------------------------------- /source/src/debugger/uMakeBPstubs-rs6000: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "//###################### uLocalDebuggerHandler #########################" 3 | echo "// generated automatically => do not change !" 4 | echo 5 | echo "class uLocalDebuggerHandler {" 6 | echo "public:" 7 | echo " uLocalDebuggerHandler() {}" 8 | echo "};" 9 | -------------------------------------------------------------------------------- /source/src/debugger/uMakeBPstubs-unknown: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "//###################### uLocalDebuggerHandler #########################" 3 | echo "// generated automatically => do not change !" 4 | echo 5 | echo "class uLocalDebuggerHandler {" 6 | echo "public:" 7 | echo " uLocalDebuggerHandler() {}" 8 | echo "};" 9 | -------------------------------------------------------------------------------- /source/src/debugger/uMakeBPstubs-x86_64: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "//###################### uLocalDebuggerHandler #########################" 3 | echo "// generated automatically => do not change !" 4 | echo 5 | echo "class uLocalDebuggerHandler {" 6 | echo "public:" 7 | echo " uLocalDebuggerHandler() {}" 8 | echo "};" 9 | -------------------------------------------------------------------------------- /source/src/examples/AbortExit.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard Bilson 2003 4 | // 5 | // AbortExit.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Fri Dec 19 10:33:58 2003 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Fri Feb 25 06:58:13 2022 11 | // Update Count : 20 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | using namespace std; 32 | 33 | enum Mode { SPIN, EXIT, UABORT, EXPLODE, ABORT, ASSERT, RETURN, PTHREAD_RETURN } mode; 34 | 35 | void *spinner( void * ) { 36 | for ( ;; ); 37 | } // spinner 38 | 39 | _Task worker { 40 | void main() { 41 | switch( mode ) { 42 | case SPIN: 43 | for ( ;; ) {} 44 | case EXIT: 45 | exit( EXIT ); 46 | case UABORT: 47 | abort( "worker %d %s", UABORT, "text" ); 48 | case EXPLODE: 49 | kill( getpid(), SIGKILL ); 50 | for ( ;; ) {} // delay until signal delivered to some kernel thread 51 | case ABORT: 52 | abort(); 53 | case ASSERT: 54 | assert( false ); 55 | default: ; 56 | } // switch 57 | // CONTROL NEVER REACHES HERE! 58 | } // main 59 | public: 60 | worker( uCluster &c ) : uBaseTask( c ) {} 61 | }; // worker 62 | 63 | int main( int argc, char *argv[] ) { 64 | if ( argc <= 1 ) { 65 | cerr << "usage: " << argv[0] << " [0-7]" << endl; 66 | exit( EXIT_FAILURE ); 67 | } // if 68 | mode = (Mode)atoi( argv[1] ); 69 | 70 | switch (mode) { 71 | case RETURN: 72 | uRetCode = RETURN; 73 | return; 74 | case PTHREAD_RETURN: 75 | uRetCode = PTHREAD_RETURN; 76 | pthread_t pt; 77 | pthread_create( &pt, nullptr, spinner, nullptr ); 78 | return; 79 | default: 80 | uCluster cluster; 81 | uProcessor processor( cluster ); 82 | worker t( cluster ); 83 | uSemaphore s( 0 ); 84 | s.P(); 85 | } // switch 86 | } // main 87 | -------------------------------------------------------------------------------- /source/src/examples/Accept.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2011 4 | // 5 | // Accept.cc -- Check dynamically nested accepting returns to the correct code after the accept clause that accepted the 6 | // call. 7 | // 8 | // Author : Peter A. Buhr 9 | // Created On : Mon Mar 21 18:16:14 2011 10 | // Last Modified By : Peter A. Buhr 11 | // Last Modified On : Fri Feb 25 06:58:44 2022 12 | // Update Count : 7 13 | // 14 | // This library is free software; you can redistribute it and/or modify it 15 | // under the terms of the GNU Lesser General Public License as published by the 16 | // Free Software Foundation; either version 2.1 of the License, or (at your 17 | // option) any later version. 18 | // 19 | // This library is distributed in the hope that it will be useful, but WITHOUT 20 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 22 | // for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public License 25 | // along with this library. 26 | // 27 | 28 | #include 29 | using namespace std; 30 | 31 | 32 | _Task T1 { 33 | int check; 34 | void main(); 35 | public: 36 | void X(); 37 | void Y(); 38 | void Z(); 39 | }; 40 | 41 | _Task T0 { 42 | T1 &t1; 43 | void main() { 44 | t1.Y(); 45 | } 46 | public: 47 | T0( T1 &t1 ) : t1( t1 ) {} 48 | }; 49 | 50 | void T1::X() { 51 | check = 1; 52 | } 53 | void T1::Y() { 54 | check = 2; 55 | X(); 56 | check = 2; 57 | } 58 | void T1::Z() { 59 | check = 3; 60 | T0 to( *this ); 61 | _Accept( X ) { 62 | assert( check == 1 ); 63 | } or _Accept( Y ) { 64 | assert( check == 2 ); 65 | } or _Accept( Z ) { 66 | assert( check == 3 ); 67 | } 68 | check = 3; 69 | } 70 | void T1::main() { 71 | for ( ;; ) { 72 | _Accept( ~T1 ) { 73 | break; 74 | } or _Accept( X ) { 75 | assert( check == 1 ); 76 | } or _Accept( Y ) { 77 | assert( check == 2 ); 78 | } or _Accept( Z ) { 79 | assert( check == 3 ); 80 | } 81 | } 82 | } 83 | 84 | _Task T2 { 85 | T1 t1; 86 | void main() { 87 | t1.X(); 88 | t1.Y(); 89 | t1.Z(); 90 | } 91 | }; 92 | 93 | int main() { 94 | T1 t1; 95 | t1.X(); 96 | uBaseTask::yield( 5 ); 97 | t1.Y(); 98 | t1.Z(); 99 | T2 t2; 100 | cout << "successful completion" << endl; 101 | } 102 | -------------------------------------------------------------------------------- /source/src/examples/ActorDeviceDriver.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pabuhr/uCPP/b637d596f2c24f052826927705e89841143a5c72/source/src/examples/ActorDeviceDriver.data -------------------------------------------------------------------------------- /source/src/examples/ActorHello.cc: -------------------------------------------------------------------------------- 1 | // 2 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2016 3 | // 4 | // ActorHello.cc -- 5 | // 6 | // Author : Peter A. Buhr 7 | // Created On : Mon Dec 19 08:23:31 2016 8 | // Last Modified By : Peter A. Buhr 9 | // Last Modified On : Tue Apr 26 15:06:02 2022 10 | // Update Count : 16 11 | // 12 | // This library is free software; you can redistribute it and/or modify it 13 | // under the terms of the GNU Lesser General Public License as published by the 14 | // Free Software Foundation; either version 2.1 of the License, or (at your 15 | // option) any later version. 16 | // 17 | // This library is distributed in the hope that it will be useful, but WITHOUT 18 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 20 | // for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public License 23 | // along with this library. 24 | // 25 | 26 | #include 27 | using namespace std; 28 | #include 29 | 30 | 31 | struct StrMsg : public uActor::Message { // actor message 32 | string val; 33 | StrMsg( string val ) : Message( uActor::Delete ), val( val ) {} 34 | }; // StrMsg 35 | 36 | _Actor Hello { 37 | Allocation receive( Message & str ) { 38 | Case( StrMsg, str ) { // determine message kind 39 | osacquire acq( cout ); 40 | cout << str_d->val; // access message value 41 | if ( str_d->val == "hello" ) { 42 | cout << ", hello back at you!" << endl; 43 | } else { 44 | cout << ", do not understand?" << endl; 45 | } // if 46 | } else Case( StopMsg, str ) { 47 | return Delete; // delete actor 48 | } // Case 49 | return Nodelete; // reuse actor 50 | } // Hello::receive 51 | }; // Hello 52 | 53 | int main() { 54 | uActor::start(); // start actor system 55 | *new Hello() | *new StrMsg( "hello" ) | *new StrMsg( "bonjour" ) | uActor::stopMsg; 56 | *new Hello() | *new StrMsg( "hello" ) | *new StrMsg( "buenos dias" ) | uActor::stopMsg; 57 | *new Hello() | *new StrMsg( "hello" ) | *new StrMsg( "你好" ) | uActor::stopMsg; 58 | uActor::stop(); // wait for all actors to terminate 59 | } // main 60 | 61 | // Local Variables: // 62 | // compile-command: "u++-work -g -O2 -multi ActorHello.cc" // 63 | // End: // 64 | -------------------------------------------------------------------------------- /source/src/examples/ActorInherit.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) Peter A. Buhr 2016 3 | // 4 | // ActorInherit.cc -- 5 | // 6 | // Author : Peter A. Buhr 7 | // Created On : Fri Dec 23 17:05:06 2016 8 | // Last Modified By : Peter A. Buhr 9 | // Last Modified On : Tue Apr 26 13:06:48 2022 10 | // Update Count : 13 11 | // 12 | // This library is free software; you can redistribute it and/or modify it 13 | // under the terms of the GNU Lesser General Public License as published by the 14 | // Free Software Foundation; either version 2.1 of the License, or (at your 15 | // option) any later version. 16 | // 17 | // This library is distributed in the hope that it will be useful, but WITHOUT 18 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 20 | // for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public License 23 | // along with this library. 24 | // 25 | 26 | #include 27 | using namespace std; 28 | #include 29 | 30 | _Actor B { 31 | Allocation receive( Message & ) { return Finished; } 32 | int i; 33 | protected: 34 | void preStart() { 35 | osacquire( cout ) << "B" << endl; 36 | } // B::preStart 37 | public: 38 | B() {} 39 | B( int i ) { B::i = i; } 40 | }; // B 41 | 42 | _Actor D : public B { 43 | void preStart() { 44 | B::preStart(); // call base member 45 | osacquire( cout ) << "D" << endl; 46 | } // D::preStart 47 | Allocation receive( Message & ) { return Finished; } 48 | public: 49 | D() {} 50 | D( int i ) : B( i ) {} 51 | }; // D 52 | 53 | int main() { 54 | uActor::start(); // start actor system 55 | B b; 56 | D d; 57 | // Output is non-deterministic because actor b or d may run first. 58 | b | uActor::stopMsg; 59 | d | uActor::stopMsg; 60 | uActor::stop(); // wait for all actors to terminate 61 | } // main 62 | 63 | // Local Variables: // 64 | // compile-command: "u++-work -g -O2 -multi ActorInherit.cc" // 65 | // End: // 66 | -------------------------------------------------------------------------------- /source/src/examples/ActorMatrixSum.cc: -------------------------------------------------------------------------------- 1 | // 2 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2016 3 | // 4 | // ActorMatrixSum.cc -- 5 | // 6 | // Author : Peter A. Buhr 7 | // Created On : Sat Dec 29 16:36:02 2018 8 | // Last Modified By : Peter A. Buhr 9 | // Last Modified On : Sun Apr 24 18:28:21 2022 10 | // Update Count : 11 11 | // 12 | // This library is free software; you can redistribute it and/or modify it 13 | // under the terms of the GNU Lesser General Public License as published by the 14 | // Free Software Foundation; either version 2.1 of the License, or (at your 15 | // option) any later version. 16 | // 17 | // This library is distributed in the hope that it will be useful, but WITHOUT 18 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 20 | // for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public License 23 | // along with this library. 24 | // 25 | 26 | #include 27 | using namespace std; 28 | #include 29 | 30 | 31 | _Actor Adder { 32 | int * row, cols, & subtotal; // communication 33 | 34 | Allocation receive( Message & ) { 35 | subtotal = 0; 36 | for ( int c = 0; c < cols; c += 1 ) { 37 | subtotal += row[c]; 38 | } // for 39 | return Delete; 40 | } // Adder::receive 41 | public: 42 | Adder( int row[], int cols, int & subtotal ) : 43 | row( row ), cols( cols ), subtotal( subtotal ) {} 44 | }; // Adder 45 | 46 | int main() { 47 | enum { rows = 10, cols = 10 }; 48 | int matrix[rows][cols], subtotals[rows], total = 0; 49 | 50 | for ( unsigned int r = 0; r < rows; r += 1 ) { // initialize matrix 51 | for ( unsigned int c = 0; c < cols; c += 1 ) { 52 | matrix[r][c] = 1; 53 | } // for 54 | } // for 55 | uActor::start(); // start actor system 56 | for ( unsigned int r = 0; r < rows; r += 1 ) { // actor per row 57 | *(new Adder( matrix[r], cols, subtotals[r] )) | uActor::startMsg; 58 | } // for 59 | uActor::stop(); // wait for all actors to terminate 60 | for ( int r = 0; r < rows; r += 1 ) { // wait for threads to finish 61 | total += subtotals[r]; // total subtotals 62 | } 63 | cout << total << endl; 64 | } // main 65 | 66 | // Local Variables: // 67 | // compile-command: "u++-work -g -O2 -multi ActorMatrixSum.cc" // 68 | // End: // 69 | -------------------------------------------------------------------------------- /source/src/examples/ActorPhoneNo.data: -------------------------------------------------------------------------------- 1 | +1(876)343-8760 2 | (876)343-8760 3 | (800)555-1212 4 | 456-9807 5 | 786-5555 6 | +1189-6543 7 | 789 6543 8 | (888)345-879 9 | -8790 10 | 5555 11 | -------------------------------------------------------------------------------- /source/src/examples/Array.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2024 4 | // 5 | // Array.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Jun 13 14:39:12 2024 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Thu Jun 13 14:45:49 2024 11 | // Update Count : 2 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using namespace std; 29 | 30 | struct Obj { 31 | int i, j; 32 | Obj( int i ) : i{i}, j{0} {} 33 | Obj( int i, int j ) : i{i}, j{j} {} 34 | }; 35 | ostream & operator<<( ostream & os, const Obj & obj ) { 36 | return os << '(' << obj.i << ',' << obj.j << ')'; 37 | } 38 | 39 | int main() { 40 | // int size; 41 | // cin >> size; 42 | enum { size = 20 }; 43 | uArray( Obj, arr, size ); // VLA, no construction 44 | 45 | // ALL SUBSCRIPTING IS CHECKED 46 | for ( int i = 0; i < size; i += 1 ) { 47 | arr[i]( i, i ); // call 2 value constructor 48 | cout << *arr[i] << ' '; 49 | } // for 50 | cout << endl; 51 | 52 | arr[3] = arr[7]; 53 | Obj fred( 3 ); 54 | arr[12] = fred; 55 | arr[14] = 3; // call 1 value constructor 56 | arr[15] = (Obj){ 3, 4 }; 57 | 58 | for ( int i = 0; i < size; i += 1 ) { 59 | cout << *arr[i] << ' '; 60 | } // for 61 | cout << endl; 62 | cout << endl; 63 | 64 | // arr[100]; // subscript error 65 | 66 | uArrayPtr( Obj, arrp, size ); 67 | for ( int i = 0; i < size; i += 1 ) { 68 | arrp[i]( i, i ); // call 2 value constructor 69 | cout << *arrp[i] << ' '; 70 | } // for 71 | cout << endl; 72 | 73 | arrp[3] = arrp[7]; 74 | arrp[12] = fred; 75 | arrp[14] = 3; // call 1 value constructor 76 | arrp[15] = (Obj){ 3, 4 }; 77 | 78 | for ( int i = 0; i < size; i += 1 ) { 79 | cout << *arrp[i] << ' '; 80 | } // for 81 | cout << endl; 82 | 83 | // arrp[100]; // subscript error 84 | } 85 | -------------------------------------------------------------------------------- /source/src/examples/Atomic.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Richard C. Bilson 2007 4 | // 5 | // Atomic.cc -- 6 | // 7 | // Author : Richard C. Bilson 8 | // Created On : Mon Sep 10 16:47:22 2007 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Tue Apr 26 08:18:52 2022 11 | // Update Count : 17 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using namespace std; 29 | 30 | #define NPROCS 8 31 | #define NTASKS 8 32 | #define NITER 1000000 33 | 34 | volatile int locn1 = 0, locn2 = 0; 35 | 36 | _Task IncTester { 37 | void main() { 38 | int cur; 39 | for ( int i = 0; i < NITER; i += 1 ) { 40 | uFetchAdd( locn1, 1 ); 41 | uFetchAdd( locn1, -1 ); 42 | 43 | do { 44 | cur = locn2; 45 | } while( ! uCompareAssign( locn2, cur, cur + 1 ) ); 46 | do { 47 | cur = locn2; 48 | } while( ! uCompareAssign( locn2, cur, cur - 1 ) ); 49 | } // for 50 | } // IncTester::main 51 | }; // IncTester 52 | 53 | int main() { 54 | uProcessor p[ NPROCS - 1 ] __attribute__(( unused )); 55 | { 56 | IncTester testers[ NTASKS ] __attribute__(( unused )); 57 | } 58 | if ( locn1 == 0 && locn2 == 0 ) { 59 | cout << "successful completion" << endl; 60 | } else { 61 | cout << "error: expected values 0, 0 but got values " << locn1 << ", " << locn2 << endl; 62 | } // if 63 | } // main 64 | -------------------------------------------------------------------------------- /source/src/examples/BitSet.cc: -------------------------------------------------------------------------------- 1 | #include "uBitSet.h" 2 | #include 3 | using namespace std; 4 | 5 | #define NBITS 128 6 | 7 | template< unsigned int n > void printBitSet( uBitSet< n > set ) { 8 | for ( unsigned int i = 0; i < n; i += 1 ) { 9 | if ( i % 8 == 0 && i != 0 ) cout << "_"; 10 | cout << (set.isSet( i ) ? "T" : "F"); 11 | } // for 12 | cout << endl; 13 | } 14 | 15 | #define SANITY_CHECK(set) if ( !set.isSet( set.ffs() ) ) abort() 16 | 17 | int main() { 18 | cout << ffs(0) << " " << ffs(3) << " " << ffs(4) << " " << ffs( 8 ) << endl; 19 | uBitSet< NBITS > t; 20 | t.clrAll(); 21 | printBitSet( t ); 22 | cout << "first set is " << t.ffs() << endl; 23 | t.clrAll(); 24 | t.set( 0 ); t.set( 1 ); 25 | printBitSet( t ); 26 | cout << "first set is " << t.ffs() << endl; 27 | t.clrAll(); 28 | t.set( 2 ); 29 | printBitSet( t ); 30 | cout << "first set is " << t.ffs() << endl; 31 | t.clrAll(); 32 | t.set( 3 ); 33 | printBitSet( t ); 34 | cout << "first set is " << t.ffs() << endl; 35 | 36 | uBitSet< NBITS > a, b; 37 | a.setAll(); 38 | cout << "a: "; 39 | printBitSet( a ); 40 | cout << "first set is " << a.ffs() << endl; 41 | a.clr( 0 ); 42 | a.clr( 4 ); 43 | a.clr( a.size() - 1 ); 44 | a.clr( 31 ); 45 | a.clr( a.size() / 2 ); 46 | cout << "a: "; 47 | printBitSet( a ); 48 | cout << "first set is " << a.ffs() << endl; 49 | 50 | b.clrAll(); 51 | cout << "b: "; 52 | printBitSet( b ); 53 | cout << "first set is " << b.ffs() << endl; 54 | b.set( b.size() - 1 ); 55 | b.set( b.size() / 2 ); 56 | cout << "b: "; 57 | printBitSet( b ); 58 | cout << "first set is " << b.ffs() << endl; 59 | b.clr( b.size() / 2 ); 60 | cout << "b: "; 61 | printBitSet( b ); 62 | cout << "first set is " << b.ffs() << endl; 63 | } 64 | 65 | // Local Variables: // 66 | // compile-command: "g++ -g -Wall example_BitSet.cc" // 67 | // End: // 68 | -------------------------------------------------------------------------------- /source/src/examples/DeleteProcessor.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2010 4 | // 5 | // DeleteProcessor.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Sun Jul 18 11:03:54 2010 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Apr 24 09:50:18 2022 11 | // Update Count : 7 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using namespace std; 29 | 30 | _Task worker { 31 | void main() { 32 | migrate( clus ); 33 | cout << "Task " << &uThisTask() << " deleting processor " << &uThisProcessor() << "\n"; 34 | delete &uThisProcessor(); 35 | cout << "Task " << &uThisTask() << " now on processor " << &uThisProcessor() << "\n"; 36 | yield(); 37 | cout << "Task " << &uThisTask() << " still on processor " << &uThisProcessor() << "\n"; 38 | } 39 | 40 | uCluster &clus; 41 | public: 42 | worker( uCluster &cl ): clus( cl ) {} 43 | }; // worker 44 | 45 | int main(){ 46 | uCluster cluster; 47 | uProcessor *processor = new uProcessor( cluster ); 48 | cout << "Task main created processor " << processor << "\n"; 49 | { 50 | worker f( cluster ); 51 | sleep( 2 ); 52 | processor = new uProcessor( cluster ); 53 | cout << "Task main created processor " << processor << "\n"; 54 | } 55 | delete processor; 56 | cout << "successful completion\n"; 57 | } 58 | -------------------------------------------------------------------------------- /source/src/examples/EHM10.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2004 4 | // 5 | // EHM10.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Mon Mar 22 21:17:24 2004 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sat Oct 7 08:06:27 2023 11 | // Update Count : 15 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using std::cout; 29 | using std::endl; 30 | 31 | _Exception R1 { 32 | public: 33 | int &i; 34 | R1( int &i ) : i(i) {} 35 | }; 36 | 37 | _Exception R2 { 38 | public: 39 | int &i; 40 | R2( int &i ) : i(i) {} 41 | }; 42 | 43 | void f( int &i ); 44 | void g( int &i ); 45 | 46 | void f( int &i ) { 47 | i -= 1; 48 | cout << "f, i:" << i << endl; 49 | if ( i > 5 ) { 50 | try { 51 | if ( i < 10 ) _Resume R2(i); 52 | try { 53 | g( i ); 54 | } _CatchResume( R2 &r ) { 55 | r.i -= 1; 56 | cout << "h2, i:" << r.i << endl; 57 | g( r.i ); 58 | } // if 59 | } _CatchResume( R1 &r ) { 60 | r.i -= 1; 61 | cout << "h1, i:" << r.i << endl; 62 | f( r.i ); 63 | } // try 64 | } else { 65 | if ( i > -5 ) _Resume R2(i); 66 | } // if 67 | } 68 | 69 | void g( int &i ) { 70 | i -= 1; 71 | cout << "g, i:" << i << endl; 72 | if ( i > 10 ) { 73 | try { 74 | f( i ); 75 | } _CatchResume( R2 &r ) { 76 | r.i -= 1; 77 | cout << "h2, i:" << r.i << endl; 78 | g( r.i ); 79 | } // try 80 | try { 81 | f( i ); 82 | } _CatchResume( R1 &r ) { 83 | r.i -= 1; 84 | cout << "h3, i:" << r.i << endl; 85 | } // try 86 | _Resume R1(i); 87 | } 88 | } 89 | int main() { 90 | int i = 20; 91 | f( i ); 92 | } 93 | 94 | // Local Variables: // 95 | // tab-width: 4 // 96 | // End: // 97 | -------------------------------------------------------------------------------- /source/src/examples/EHM2.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1998 4 | // 5 | // EHM2.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Tue Oct 27 21:24:48 1998 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sat Oct 7 08:06:53 2023 11 | // Update Count : 44 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | _Exception xxx { 29 | public: 30 | uBaseTask *tid; 31 | xxx( uBaseTask *tid ) : tid(tid) {} 32 | }; 33 | 34 | _Exception yyy { 35 | public: 36 | uBaseTask *tid; 37 | yyy( uBaseTask *tid ) : tid(tid) {} 38 | }; 39 | 40 | 41 | _Task fred { 42 | void r( int i ) { 43 | if ( i == 0 ) { 44 | _Throw xxx( &uThisTask() ); 45 | } else { 46 | r( i - 1 ); 47 | } // if 48 | } // fred::r 49 | 50 | void s( int i ) { 51 | if ( i == 0 ) { 52 | try { 53 | r( 5 ); 54 | } catch( xxx & e ) { 55 | assert( e.tid == &uThisTask() ); 56 | _Throw; 57 | } 58 | } else { 59 | s( i - 1 ); 60 | } // if 61 | } // fred::s 62 | 63 | void t( int i ) { 64 | if ( i == 0 ) { 65 | try { 66 | s( 5 ); 67 | } catch( xxx & e ) { 68 | assert( e.tid == &uThisTask() ); 69 | _Throw yyy( &uThisTask() ); 70 | } 71 | } else { 72 | t( i - 1 ); 73 | } // if 74 | } // fred::t 75 | 76 | void main() { 77 | for ( int i = 0; i < 5000; i += 1 ) { 78 | // for ( int i = 0; i < 5; i += 1 ) { 79 | try { 80 | t( 5 ); 81 | } catch( yyy & e ) { 82 | assert( e.tid == &uThisTask() ); 83 | } // try 84 | } // for 85 | } // fred::main 86 | }; // fred 87 | 88 | int main() { 89 | uProcessor processors[3] __attribute__(( unused )); // more than one processor 90 | fred f[4] __attribute__(( unused )); 91 | } // main 92 | -------------------------------------------------------------------------------- /source/src/examples/Errno.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2012 4 | // 5 | // Errno.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Wed Sep 12 08:45:31 2012 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Apr 24 18:28:41 2022 11 | // Update Count : 3 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using namespace std; 29 | 30 | _Task Worker { 31 | void main() { 32 | for ( int i = 0; i < 1000000; i += 1 ) { 33 | errno = i; 34 | yield(); 35 | if ( i != errno ) abort( "Error: interference on errno %p %p %d %d\n", &uThisTask(), &uThisProcessor(), i, errno ); 36 | } // for 37 | } // Worker::main 38 | }; // Worker 39 | 40 | int main() { 41 | uProcessor p[3]; 42 | Worker w[10]; 43 | } 44 | -------------------------------------------------------------------------------- /source/src/examples/Fib.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // Fib.cc -- Produce the fibonacci numbers in sequence on each call. 6 | // 7 | // No explicit states, communication with argument-parameter mechanism between suspend and resume 8 | // 9 | // Demonstrate multiple instances of the same coroutine. 10 | // 11 | // Author : Peter A. Buhr 12 | // Created On : Thu Aug 2 11:55:37 1990 13 | // Last Modified By : Peter A. Buhr 14 | // Last Modified On : Wed Apr 20 23:04:08 2022 15 | // Update Count : 42 16 | // 17 | // This library is free software; you can redistribute it and/or modify it 18 | // under the terms of the GNU Lesser General Public License as published by the 19 | // Free Software Foundation; either version 2.1 of the License, or (at your 20 | // option) any later version. 21 | // 22 | // This library is distributed in the hope that it will be useful, but WITHOUT 23 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 24 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 25 | // for more details. 26 | // 27 | // You should have received a copy of the GNU Lesser General Public License 28 | // along with this library. 29 | // 30 | 31 | #include 32 | using std::cout; 33 | using std::endl; 34 | 35 | _Coroutine fibonacci { 36 | int fn; 37 | 38 | void main() { 39 | int fn1, fn2; 40 | 41 | fn = 1; // special case f0 42 | fn1 = fn; 43 | suspend(); 44 | fn = 1; // special case f1 45 | fn2 = fn1; 46 | fn1 = fn; 47 | suspend(); 48 | for ( ;; ) { // general case fn 49 | fn = fn1 + fn2; 50 | suspend(); 51 | fn2 = fn1; 52 | fn1 = fn; 53 | } // for 54 | } // fibonacci::main 55 | public: 56 | int next() { 57 | resume(); 58 | return fn; 59 | }; // next 60 | }; // fibonacci 61 | 62 | int main() { 63 | const int NoOfFibs = 10; 64 | fibonacci f1, f2; // create two fibonacci generators 65 | int i; 66 | 67 | cout << "Fibonacci Numbers" << endl; 68 | for ( i = 1; i <= NoOfFibs; i += 1 ) { 69 | cout << f1.next() << " " << f2.next() << endl; 70 | } // for 71 | cout << "successful completion" << endl; 72 | } // main 73 | 74 | // Local Variables: // 75 | // compile-command: "u++ Fib.cc" // 76 | // End: // 77 | -------------------------------------------------------------------------------- /source/src/examples/FlexArray.cc: -------------------------------------------------------------------------------- 1 | #include "uFlexArray.h" 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | uFlexArray a( 1 ), b( 1 ); 7 | int i; 8 | for ( i = 0; i < 6; i += 1 ) { 9 | a.add( i ); 10 | } // for 11 | for ( i = 0; i < a.size(); i += 1 ) { 12 | cout << a[i] << endl; 13 | } // for 14 | b = a; 15 | for ( i = 0; i < b.size(); i += 1 ) { 16 | cout << b[i] << endl; 17 | } // for 18 | for ( i = 0; i < b.size(); i += 1 ) { 19 | b[i] += 1; 20 | cout << b[i] << endl; 21 | } // for 22 | b.remove(2); 23 | b.remove(4); 24 | for ( i = 0; i < b.size(); i += 1 ) { 25 | cout << b[i] << endl; 26 | } // for 27 | } 28 | 29 | // Local Variables: // 30 | // compile-command: "u++ example_FlexArray.cc" // 31 | // End: // 32 | -------------------------------------------------------------------------------- /source/src/examples/Futures2.cc: -------------------------------------------------------------------------------- 1 | // 2 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2015 3 | // 4 | // Futures2.cc -- 5 | // 6 | // Author : Peter A. Buhr 7 | // Created On : Fri Dec 2 16:20:24 2022 8 | // Last Modified By : Peter A. Buhr 9 | // Last Modified On : Fri Dec 2 16:21:24 2022 10 | // Update Count : 1 11 | // 12 | // This library is free software; you can redistribute it and/or modify it 13 | // under the terms of the GNU Lesser General Public License as published by the 14 | // Free Software Foundation; either version 2.1 of the License, or (at your 15 | // option) any later version. 16 | // 17 | // This library is distributed in the hope that it will be useful, but WITHOUT 18 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 20 | // for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public License 23 | // along with this library. 24 | // 25 | 26 | #include 27 | using namespace std; 28 | #include 29 | 30 | Future_ISM fi; 31 | Future_ISM fip; 32 | Future_ISM fd; 33 | struct Msg { int i, j; }; 34 | Future_ISM fm; 35 | Future_ISM fmp; 36 | struct Stop {}; 37 | Future_ISM fs; 38 | struct Cont {}; 39 | Future_ISM fc; 40 | 41 | int x = 7; 42 | Msg fred{ 12, 15 }; 43 | 44 | _Task Worker { 45 | void main() { 46 | for ( ;; ) { 47 | _Select( fi ) { cout << fi() << endl; fi.reset(); } 48 | and _Select( fip ) { cout << fip() << " " << *fip() << endl; fip.reset(); } 49 | and _Select( fd ) { cout << fd() << endl; fd.reset(); } 50 | and _Select( fm ) { cout << fm().i << " " << fm().j << endl; fm.reset(); } 51 | and _Select( fmp ) { cout << fmp() << " " << fmp()->i << " " << fmp()->j << endl; fmp.reset(); } 52 | or _Select( fs ) { cout << "stop" << endl; break; } 53 | fc.delivery( (Cont){} ); // synchronize 54 | } // for 55 | } // Worker::main 56 | }; // Worker 57 | 58 | int main() { 59 | Worker worker; 60 | uProcessor p; 61 | for ( int i = 0; i < 10; i += 1 ) { 62 | fi.delivery( i ); 63 | fip.delivery( &x ); 64 | fd.delivery( i + 2.5 ); 65 | fm.delivery( (Msg){ i, 2 } ); 66 | fmp.delivery( &fred ); 67 | fc(); fc.reset(); // wait for 3 futures to be processed 68 | cout << endl; 69 | } 70 | fs.delivery( (Stop){} ); 71 | } // wait for worker to terminate 72 | -------------------------------------------------------------------------------- /source/src/examples/IO/File.cc: -------------------------------------------------------------------------------- 1 | // 2 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 3 | // 4 | // File.cc -- Print multiple copies of the same file to standard output 5 | // 6 | // Author : Peter A. Buhr 7 | // Created On : Tue Jan 7 08:44:56 1992 8 | // Last Modified By : Peter A. Buhr 9 | // Last Modified On : Sat Jan 20 08:03:21 2024 10 | // Update Count : 47 11 | // 12 | // This library is free software; you can redistribute it and/or modify it 13 | // under the terms of the GNU Lesser General Public License as published by the 14 | // Free Software Foundation; either version 2.1 of the License, or (at your 15 | // option) any later version. 16 | // 17 | // This library is distributed in the hope that it will be useful, but WITHOUT 18 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 20 | // for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public License 23 | // along with this library. 24 | // 25 | 26 | #include 27 | #include 28 | using std::cout; 29 | using std::cerr; 30 | using std::endl; 31 | 32 | _Task Copier { 33 | uFile &input; 34 | 35 | void main() { 36 | uFile::FileAccess in( input, O_RDONLY ); 37 | int count; 38 | char buf[1]; 39 | 40 | for ( int i = 0;; i += 1 ) { // copy in-file to out-file 41 | count = in.read( buf, sizeof( buf ) ); 42 | if ( count == 0 ) break; // eof ? 43 | cout << buf[0]; 44 | if ( i % 20 == 0 ) yield(); 45 | } // for 46 | } // Copier::main 47 | public: 48 | Copier( uFile &in ) : input( in ) { 49 | } // Copier::Copier 50 | }; // Copier 51 | 52 | int main( int argc, char *argv[] ) { 53 | switch ( argc ) { 54 | case 2: 55 | break; 56 | default: 57 | cerr << "Usage: " << argv[0] << " input-file" << std::endl; 58 | exit( EXIT_FAILURE ); 59 | } // switch 60 | 61 | uFile input( argv[1] ); // connect with UNIX files 62 | { 63 | Copier c1( input ), c2( input ); 64 | } 65 | } // main 66 | 67 | // Local Variables: // 68 | // compile-command: "u++ File.cc" // 69 | // End: // 70 | -------------------------------------------------------------------------------- /source/src/examples/IO/NBFile.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // NBFile.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Tue Apr 27 20:39:18 1993 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Thu Apr 21 18:42:51 2022 11 | // Update Count : 27 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | #include 29 | using std::cin; 30 | 31 | char ch = '0'; // shared by reader and writer 32 | 33 | _Task Reader { 34 | void main() { 35 | char tch; 36 | 37 | for ( ;; ) { 38 | cin >> tch; // read number from stdin 39 | if ( tch != '\n' ) ch = tch; 40 | if ( cin.fail() ) break; 41 | } // for 42 | } // Reader::main 43 | }; // Reader 44 | 45 | _Task Writer { 46 | void main() { 47 | uFile::FileAccess output( "xxx", O_WRONLY | O_CREAT | O_TRUNC, 0666 ); 48 | int i; 49 | 50 | for ( i = 0;; i += 1 ) { 51 | if ( cin.fail() ) break; 52 | if ( i % 500 == 0 ) { // don't print too much 53 | output.write( &ch, 1 ); // write number to stdout 54 | } // if 55 | yield( 1 ); 56 | } // for 57 | } // Writer::main 58 | }; // Writer 59 | 60 | int main() { 61 | Reader reader; 62 | Writer writer; 63 | } // main 64 | 65 | // Local Variables: // 66 | // compile-command: "u++ NBFile.cc" // 67 | // End: // 68 | -------------------------------------------------------------------------------- /source/src/examples/IO/NBStream.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // NBStream.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Wed Apr 28 13:23:14 1993 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Thu Apr 21 18:40:03 2022 11 | // Update Count : 32 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using std::cin; 29 | using std::cerr; 30 | 31 | int d = 0; // shared by reader and writer 32 | 33 | _Task Reader { 34 | void main() { 35 | try { 36 | for ( ;; ) { 37 | cin >> d; // read number from stdin 38 | if ( cin.fail() ) break; 39 | } // for 40 | } catch( ... ) { 41 | abort( "reader failure" ); 42 | } // try 43 | } // Reader::main 44 | }; // Reader 45 | 46 | _Task Writer { 47 | void main() { 48 | try { 49 | for ( unsigned int i = 0;; i += 1 ) { 50 | if ( cin.fail() ) break; 51 | if ( i % 500 == 0 ) { // don't print too much 52 | cerr << d; // write number to stderr (no buffering) 53 | } // if 54 | yield( 1 ); 55 | } // for 56 | } catch( ... ) { 57 | abort( "writer failure" ); 58 | } // try 59 | } // Writer::main 60 | }; // Writer 61 | 62 | int main() { 63 | Reader r; 64 | Writer w; 65 | } // main 66 | 67 | // Local Variables: // 68 | // compile-command: "u++ NBStream.cc" // 69 | // End: // 70 | -------------------------------------------------------------------------------- /source/src/examples/Matrix.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2019 4 | // 5 | // Matrix.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Mon Jul 8 11:19:32 2019 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sat Feb 18 08:27:11 2023 11 | // Update Count : 3 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using namespace std; 29 | #include 30 | 31 | struct Adder { // routine, functor or lambda 32 | int * row, cols; // communication 33 | int operator()() { // functor-call operator 34 | int subtotal = 0; 35 | for ( int c = 0; c < cols; c += 1 ) { 36 | subtotal += row[c]; 37 | } // for 38 | return subtotal; 39 | } 40 | Adder( int row[ ], int cols ) : row( row ), cols( cols ) {} 41 | }; 42 | 43 | int main() { 44 | const int rows = 10, cols = 10; 45 | int matrix[rows][cols], total = 0; 46 | 47 | for ( int r = 0; r < rows; r += 1 ) { 48 | for ( int c = 0; c < rows; c += 1 ) { 49 | matrix[r][c] = 2; 50 | } // for 51 | } // for 52 | 53 | uExecutor executor( 4 ); // kernel threads 54 | Future_ISM subtotals[rows]; 55 | Adder * adders[rows]; 56 | for ( int r = 0; r < rows; r += 1 ) { // send off work for executor 57 | adders[r] = new Adder( matrix[r], cols ); 58 | executor.sendrecv( *adders[r], subtotals[r] ); 59 | } // for 60 | for ( int r = 0; r < rows; r += 1 ) { // wait for results 61 | total += subtotals[r](); 62 | delete adders[r]; 63 | } // for 64 | cout << total << endl; 65 | } 66 | 67 | // Local Variables: // 68 | // tab-width: 4 // 69 | // End: // 70 | -------------------------------------------------------------------------------- /source/src/examples/Migrate.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // Migrate.cc -- Test migrating of tasks among clusters. 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Tue Jun 28 10:23:11 1994 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Mon Apr 25 20:51:24 2022 11 | // Update Count : 45 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using std::cout; 29 | using std::endl; 30 | 31 | unsigned int uDefaultPreemption() { 32 | return 1; 33 | } // uDefaultPreemption 34 | 35 | unsigned int uDefaultSpin() { 36 | return 10; // keep small for 1-core computer 37 | } // uDefaultSpin 38 | 39 | _Task Worker { 40 | uCluster &cluster1, &cluster2, &cluster3; 41 | 42 | void main() { 43 | const int NoOfTimes = 10000; 44 | 45 | for ( int i = 0; i < NoOfTimes; i += 1 ) { 46 | migrate( cluster3 ); 47 | migrate( cluster2 ); 48 | migrate( cluster1 ); 49 | } // for 50 | } // Worker::main 51 | public: 52 | Worker( uCluster &cluster1, uCluster &cluster2, uCluster &cluster3 ) : uBaseTask( cluster1 ), cluster1( cluster1 ), cluster2( cluster2 ), cluster3( cluster3 ) { 53 | } // Worker::Worker 54 | }; // Worker 55 | 56 | uCluster cluster1( "cluster1" ); 57 | uProcessor processor1( cluster1 ); 58 | 59 | uCluster cluster2( "cluster2" ); 60 | uProcessor processor2( cluster2 ); 61 | 62 | int main() { 63 | { 64 | Worker task1( uThisCluster(), cluster1, cluster2 ), task2( cluster2, uThisCluster(), cluster1 ), task3( cluster1, cluster2, uThisCluster() ); 65 | } 66 | cout << "successful completion" << endl; 67 | } // main 68 | 69 | // Local Variables: // 70 | // compile-command: "u++ Migrate.cc" // 71 | // End: // 72 | -------------------------------------------------------------------------------- /source/src/examples/MonConditionBB.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // MonConditionBB.cc -- Generic bounded buffer problem using a monitor and condition variables 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Aug 2 11:35:05 1990 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Mon Dec 19 22:26:27 2016 11 | // Update Count : 58 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | template _Monitor BoundedBuffer { 29 | const int size; // number of buffer elements 30 | int front, back; // position of front and back of queue 31 | int count; // number of used elements in the queue 32 | ELEMTYPE *Elements; 33 | uCondition BufFull, BufEmpty; 34 | public: 35 | BoundedBuffer( const int size = 10 ) : size( size ) { 36 | front = back = count = 0; 37 | Elements = new ELEMTYPE[size]; 38 | } // BoundedBuffer::BoundedBuffer 39 | 40 | ~BoundedBuffer() { 41 | delete [] Elements; 42 | } // BoundedBuffer::~BoundedBuffer 43 | 44 | _Nomutex int query() { 45 | return count; 46 | } // BoundedBuffer::query 47 | 48 | void insert( ELEMTYPE elem ) { 49 | if ( count == size ) { 50 | BufFull.wait(); 51 | } // if 52 | 53 | Elements[back] = elem; 54 | back = ( back + 1 ) % size; 55 | count += 1; 56 | 57 | BufEmpty.signal(); 58 | }; // BoundedBuffer::insert 59 | 60 | ELEMTYPE remove() { 61 | ELEMTYPE elem; 62 | 63 | if ( count == 0 ) { 64 | BufEmpty.wait(); 65 | } // if 66 | 67 | elem = Elements[front]; 68 | front = ( front + 1 ) % size; 69 | count -= 1; 70 | 71 | BufFull.signal(); 72 | return elem; 73 | }; // BoundedBuffer::remove 74 | }; // BoundedBuffer 75 | 76 | #include "ProdConsDriver.i" 77 | 78 | // Local Variables: // 79 | // tab-width: 4 // 80 | // compile-command: "u++ MonConditionBB.cc" // 81 | // End: // 82 | -------------------------------------------------------------------------------- /source/src/examples/Ownership1.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 5.0, Copyright (C) Ashif S. Harji 2005 4 | // 5 | // OwnerShip2.cc -- 6 | // 7 | // Author : Ashif S. Harji 8 | // Created On : Sun Jan 9 16:12:31 2005 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Mon Apr 25 20:51:00 2022 11 | // Update Count : 18 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using std::cout; 29 | using std::osacquire; 30 | using std::endl; 31 | 32 | _Task T; 33 | 34 | _Cormonitor CM { 35 | T *t; 36 | 37 | void main() { 38 | osacquire( cout ) << "CM::main" << endl; 39 | mem2(); 40 | } // CM::main 41 | public: 42 | void mem1( T *t ) { 43 | osacquire( cout ) << "CM::mem" << endl; 44 | CM::t = t; 45 | resume(); 46 | } // CM::mem1 47 | 48 | void mem2(); 49 | }; // CM 50 | 51 | _Task T { 52 | CM &cm; 53 | 54 | void main() { 55 | osacquire( cout ) << "T::main" << endl; 56 | cm.mem1( this ); 57 | } // T::main 58 | public: 59 | T( CM & cm ) : cm( cm ) {} 60 | 61 | void mem() { 62 | resume(); 63 | } // T::mem 64 | }; // T 65 | 66 | void CM::mem2() { 67 | osacquire( cout ) << "CM::mem2" << endl; 68 | t->mem(); 69 | } // CM::mem2 70 | 71 | _Task Worker { 72 | void main() {} 73 | }; // Worker 74 | 75 | 76 | // This test checks that creating tasks and processors not directly in main works correctly 77 | _Monitor nonMainTest { 78 | public: 79 | void test() { 80 | uProcessor processors[2]; 81 | Worker tasks[2]; 82 | } // nonMainTest::test 83 | }; // nonMainTest 84 | 85 | int main() { 86 | nonMainTest m; 87 | osacquire( cout ) << "The first test should complete" << endl; 88 | m.test(); 89 | osacquire( cout ) << "The first test successfully" << endl; 90 | osacquire( cout ) << "The second test should fail" << endl; 91 | CM cm; 92 | T t( cm ); 93 | } // main 94 | -------------------------------------------------------------------------------- /source/src/examples/Ownership3.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2006 4 | // 5 | // Ownership3.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Wed Feb 22 23:20:03 2006 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Tue Apr 26 15:08:58 2022 11 | // Update Count : 13 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using std::cout; 29 | using std::osacquire; 30 | using std::endl; 31 | 32 | _Coroutine C; // foward declaration 33 | 34 | _Monitor M { 35 | public: 36 | void mem( C &c ); 37 | }; // M 38 | 39 | _Coroutine C { 40 | M &m; 41 | 42 | void main() { 43 | m.mem( *this ); 44 | } // C::main 45 | public: 46 | C( M &m ) : m( m ) {} 47 | ~C() { 48 | cout << "Here1" << endl; 49 | } 50 | 51 | void mem() { 52 | resume(); 53 | } // C::mem 54 | 55 | void mem2() { 56 | suspend(); 57 | } // C::mem 58 | }; // C 59 | 60 | void M::mem( C &c ) { 61 | c.mem2(); 62 | } // M::mem 63 | 64 | _Task T { 65 | C &c; 66 | public: 67 | T( C &c, const char *name ) : c( c ) { 68 | setName( name ); 69 | } // T::T 70 | 71 | void mem() {} 72 | private: 73 | void main() { 74 | c.mem(); 75 | cout << "Here2" << endl; 76 | _Accept( mem ); 77 | _Accept( mem ); 78 | } // T::main 79 | }; // T 80 | 81 | int main() { 82 | M m; 83 | C c( m ); 84 | T &t = *new T( c, "T" ); 85 | t.mem(); 86 | cout << "Here3" << endl; 87 | } // main 88 | -------------------------------------------------------------------------------- /source/src/examples/PageRequests: -------------------------------------------------------------------------------- 1 | 1 2 3 4 1 2 5 1 2 3 4 5 -1 3 4 5 -1 2 | 1 2 3 4 5 1 2 3 2 1 4 5 6 7 1 2 7 3 4 5 -1 3 4 5 -1 3 | 3 2 1 2 4 3 2 3 2 5 3 -1 3 4 -1 4 | 7 2 6 4 3 7 1 4 1 5 7 1 6 4 -1 3 4 -1 5 | 1 2 3 4 2 3 5 4 3 6 4 5 -1 3 -1 6 | -------------------------------------------------------------------------------- /source/src/examples/Processor.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // Copyright (C) Peter A. Buhr 2016 4 | // 5 | // Processor.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Mon Dec 19 22:28:04 2016 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Thu Apr 21 18:39:13 2022 11 | // Update Count : 2 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using std::cout; 29 | using std::endl; 30 | 31 | volatile bool stop = false; 32 | 33 | _Task Worker { 34 | void main() { 35 | while ( ! stop ) { 36 | yield(); 37 | } 38 | } 39 | }; 40 | 41 | int main() { 42 | uProcessor *processor2 = nullptr; 43 | { 44 | Worker tasks[2]; 45 | 46 | uProcessor *processor1 = new uProcessor(); 47 | 48 | while ( &uThisProcessor() != processor1 ) { 49 | yield(); 50 | } // while 51 | 52 | processor2 = new uProcessor(); 53 | 54 | // delete processor2; 55 | delete processor1; 56 | 57 | stop = true; 58 | } 59 | cout << "here" << endl; 60 | delete processor2; 61 | } // main 62 | 63 | // Local Variables: // 64 | // compile-command: "../../bin/u++ -g -multi Processor.cc" // 65 | // End: // 66 | -------------------------------------------------------------------------------- /source/src/examples/Sleep.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Philipp E. Lim 1996 4 | // 5 | // Sleep.cc -- 6 | // 7 | // Author : Philipp E. Lim 8 | // Created On : Wed Jan 10 17:02:39 1996 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Tue Apr 26 13:05:01 2022 11 | // Update Count : 26 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using std::cout; 29 | using std::osacquire; 30 | using std::endl; 31 | 32 | volatile int x = 0, y = 1; 33 | 34 | _Task fred { 35 | void main() { 36 | for ( ;; ) { 37 | if ( x == 20 ) break; 38 | if ( x < y ) x += 1; 39 | uTime start = uClock::currTime(); 40 | _Timeout( uDuration( 1 ) ); 41 | osacquire( cout ) << "fred slept for " << uClock::currTime() - start << " seconds" << endl; 42 | } // for 43 | osacquire( cout ) << "fred finished" << endl; 44 | } // fred::main 45 | }; // fred 46 | 47 | _Task mary { 48 | void main() { 49 | for ( ;; ) { 50 | if ( y == 20 ) break; 51 | if ( y == x ) y += 1; 52 | uTime start = uClock::currTime(); 53 | _Timeout( uDuration( 2 ) ); 54 | osacquire( cout ) << "mary slept for " << uClock::currTime() - start << " seconds" << endl; 55 | } // for 56 | osacquire( cout ) << "mary finished" << endl; 57 | } // mary::main 58 | }; // mary 59 | 60 | int main() { 61 | fred f; 62 | mary m; 63 | } // main 64 | 65 | // Local Variables: // 66 | // compile-command: "u++ Sleep.cc" // 67 | // End: // 68 | -------------------------------------------------------------------------------- /source/src/examples/SpinLock.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // SpinLock.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Mon Feb 13 15:47:48 1995 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Wed Apr 20 23:10:52 2022 11 | // Update Count : 19 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | unsigned int uDefaultPreemption() { 29 | return 1; 30 | } // uDefaultPreemption 31 | 32 | void CriticalSection() { 33 | static volatile uBaseTask *CurrTid; // current task id 34 | CurrTid = &uThisTask(); // address of current task 35 | 36 | for ( int i = 1; i <= 100; i += 1 ) { // delay 37 | // perform critical section operation 38 | if ( CurrTid != &uThisTask() ) { // check for mutual exclusion violation 39 | abort( "interference" ); 40 | } // if 41 | } // for 42 | } // CriticalSection 43 | 44 | uSpinLock Lock; 45 | 46 | _Task Tester { 47 | void main() { 48 | for ( int i = 1; i <= 10000000; i += 1 ) { 49 | ::Lock.acquire(); 50 | CriticalSection(); // critical section 51 | ::Lock.release(); 52 | } // for 53 | } // main 54 | public: 55 | Tester() {} 56 | }; // Tester 57 | 58 | int main() { 59 | uProcessor processor[1] __attribute__(( unused )); // more than one processor 60 | Tester t[10]; 61 | } // main 62 | 63 | // Local Variables: // 64 | // compile-command: "../../bin/u++ -multi -g SpinLock.cc" // 65 | // End: // 66 | -------------------------------------------------------------------------------- /source/src/examples/Stack.cc: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | #include 4 | 5 | int main() { 6 | // Fred test 7 | 8 | struct Fred : public uColable { 9 | int i; 10 | Fred() { abort(); } 11 | Fred( int p ) : i( p ) {} 12 | }; 13 | 14 | uStack fred; 15 | uStackIter fredIter( fred ); 16 | Fred * f; 17 | int i; 18 | 19 | for ( ; fredIter >> f; ) { // empty list 20 | cout << f->i << ' '; 21 | } 22 | cout << "empty" << endl; 23 | 24 | for ( i = 0; i < 10; i += 1 ) { 25 | fred.push( new Fred( 2 * i ) ); 26 | } 27 | 28 | for ( fredIter.over( fred ); fredIter >> f; ) { 29 | cout << f->i << ' '; 30 | } 31 | cout << endl; 32 | 33 | cout << fred.head()->i << endl; 34 | 35 | for ( i = 0; i < 9; i += 1 ) { 36 | delete fred.pop(); 37 | } 38 | 39 | for ( fredIter.over( fred ); fredIter >> f; ) { 40 | cout << f->i << ' '; 41 | } 42 | cout << endl; 43 | 44 | for ( i = 0; i < 10; i += 1 ) { 45 | fred.push( new Fred( 2 * i + 1 ) ); 46 | } 47 | for ( fredIter.over( fred ); fredIter >> f; ) { 48 | cout << f->i << ' '; 49 | } 50 | cout << endl; 51 | 52 | for ( fredIter.over( fred ); fredIter >> f; ) { 53 | delete f; 54 | } 55 | 56 | // Mary test 57 | 58 | struct Mary: public Fred { 59 | int j; 60 | Mary() { abort(); } 61 | Mary( int p ) : Fred( p ), j( p ) {} 62 | }; 63 | 64 | uStack mary; 65 | uStackIter maryIter( mary ); 66 | Mary * m; 67 | 68 | for ( ; maryIter >> m; ) { // empty list 69 | cout << m->i << ' ' << m->j << ' '; 70 | } 71 | cout << "empty" << endl; 72 | 73 | for ( i = 0; i < 10; i += 1 ) { 74 | mary.push( new Mary( 2 * i ) ); 75 | } 76 | 77 | for ( maryIter.over( mary ); maryIter >> m; ) { 78 | cout << m->i << ' ' << m->j << ' '; 79 | } 80 | cout << endl; 81 | 82 | for ( i = 0; i < 9; i += 1 ) { 83 | delete mary.pop(); 84 | } 85 | 86 | for ( maryIter.over( mary ); maryIter >> m; ) { 87 | cout << m->i << ' ' << m->j << ' '; 88 | } 89 | cout << endl; 90 | 91 | for ( i = 0; i < 10; i += 1 ) { 92 | mary.push( new Mary( 2 * i + 1 ) ); 93 | } 94 | for ( maryIter.over( mary ); maryIter >> m; ) { 95 | cout << m->i << ' ' << m->j << ' '; 96 | } 97 | cout << endl; 98 | 99 | for ( maryIter.over( mary ); maryIter >> m; ) { 100 | delete m; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /source/src/examples/TaskAcceptBB.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // TaskAcceptBB.cc -- Generic bounded buffer using a task 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Sun Sep 15 20:24:44 1991 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Mon Dec 19 23:03:29 2016 11 | // Update Count : 75 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | template _Task BoundedBuffer { 29 | const int size; // number of buffer elements 30 | int front, back; // position of front and back of queue 31 | int count; // number of used elements in the queue 32 | ELEMTYPE *Elements; 33 | public: 34 | BoundedBuffer( const int size = 10 ) : size( size ) { 35 | front = back = count = 0; 36 | Elements = new ELEMTYPE[size]; 37 | } // BoundedBuffer::BoundedBuffer 38 | 39 | ~BoundedBuffer() { 40 | delete [] Elements; 41 | } // BoundedBuffer::~BoundedBuffer 42 | 43 | _Nomutex int query() { 44 | return count; 45 | } // BoundedBuffer::query 46 | 47 | void insert( ELEMTYPE elem ) { 48 | Elements[back] = elem; 49 | } // BoundedBuffer::insert 50 | 51 | ELEMTYPE remove() { 52 | return Elements[front]; 53 | } // BoundedBuffer::remove 54 | protected: 55 | void main() { 56 | for ( ;; ) { 57 | _Accept( ~BoundedBuffer ) 58 | break; 59 | or _When ( count != size ) _Accept( insert ) { 60 | back = ( back + 1 ) % size; 61 | count += 1; 62 | } or _When ( count != 0 ) _Accept( remove ) { 63 | front = ( front + 1 ) % size; 64 | count -= 1; 65 | } // _Accept 66 | } // for 67 | } // BoundedBuffer::main 68 | }; // BoundedBuffer 69 | 70 | #include "ProdConsDriver.i" 71 | 72 | // Local Variables: // 73 | // tab-width: 4 // 74 | // compile-command: "u++ TaskAcceptBB.cc" // 75 | // End: // 76 | -------------------------------------------------------------------------------- /source/src/examples/TaskConditionBB.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1999 4 | // 5 | // TaskConditionBB.cc -- Generic bounded buffer using a task 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Mon Nov 22 21:32:23 1999 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Mon Dec 19 23:03:34 2016 11 | // Update Count : 14 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | template _Task BoundedBuffer { 29 | const int size; // number of buffer elements 30 | uCondition NonEmpty, NonFull; 31 | int front, back; // position of front and back of queue 32 | int count; // number of used elements in the queue 33 | ELEMTYPE *Elements; 34 | public: 35 | BoundedBuffer( const int size = 10 ) : size( size ) { 36 | front = back = count = 0; 37 | Elements = new ELEMTYPE[size]; 38 | } // BoundedBuffer::BoundedBuffer 39 | 40 | ~BoundedBuffer() { 41 | delete [] Elements; 42 | } // BoundedBuffer::~BoundedBuffer 43 | 44 | _Nomutex int query() { 45 | return count; 46 | } // BoundedBuffer::query 47 | 48 | void insert( ELEMTYPE elem ) { 49 | if (count == 20) NonFull.wait(); 50 | Elements[back] = elem; 51 | back = ( back + 1 ) % size; 52 | count += 1; 53 | NonEmpty.signal(); 54 | } // BoundedBuffer::insert 55 | 56 | ELEMTYPE remove() { 57 | if (count == 0) NonEmpty.wait(); 58 | ELEMTYPE elem = Elements[front]; 59 | front = ( front + 1 ) % size; 60 | count -= 1; 61 | NonFull.signal(); 62 | return elem; 63 | } // BoundedBuffer::remove 64 | protected: 65 | void main() { 66 | for ( ;; ) { 67 | _Accept( ~BoundedBuffer ) { 68 | break; 69 | } or _Accept( insert, remove ) { 70 | } // _Accept 71 | } // for 72 | } // BoundedBuffer::main 73 | }; // BoundedBuffer 74 | 75 | #include "ProdConsDriver.i" 76 | 77 | // Local Variables: // 78 | // tab-width: 4 // 79 | // compile-command: "u++ TaskConditionBB.cc" // 80 | // End: // 81 | -------------------------------------------------------------------------------- /source/src/examples/TimeSlice.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // TimeSlice.cc -- test time slice 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Mon Apr 26 11:04:37 1993 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Fri Feb 4 14:33:47 2022 11 | // Update Count : 37 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | unsigned int uDefaultPreemption() { 29 | return 1; 30 | } // uDefaultPreemption 31 | 32 | enum { NoOfTimes = 1000 }; 33 | volatile int x = 0, y = 1; 34 | 35 | _Task T1 { 36 | void main() { 37 | for ( ;; ) { 38 | if ( x == NoOfTimes ) break; 39 | if ( x < y ) x += 1; 40 | } // for 41 | } // T1::main 42 | }; // T1 43 | 44 | _Task T2 { 45 | void main() { 46 | for ( ;; ) { 47 | if ( y == NoOfTimes ) break; 48 | if ( y == x ) y += 1; 49 | } // for 50 | } // T2::main 51 | }; // T2 52 | 53 | int main() { 54 | T1 t1; 55 | T2 t2; 56 | } // main 57 | 58 | // Local Variables: // 59 | // compile-command: "u++ TimeSlice.cc" // 60 | // End: // 61 | -------------------------------------------------------------------------------- /source/src/examples/TimeoutProcessor.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2012 4 | // 5 | // TimeoutProcessor.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Apr 5 08:06:57 2012 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Apr 24 18:27:38 2022 11 | // Update Count : 8 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using namespace std; 29 | 30 | // The processor is removed from cluster so task "t" cannot run after the timeout moves it to the ready queue on cluster 31 | // "clus". When the processor is returned to "clus", the task "t" can wakeup from the sleep and continue. 32 | 33 | _Task T { 34 | void main() { 35 | osacquire( cout ) << "start " << uThisCluster().getName() << " " << &uThisProcessor() << endl; 36 | sleep( uDuration( 5 ) ); 37 | osacquire( cout ) << "done " << uThisCluster().getName() << " " << &uThisProcessor() << endl; 38 | } // T:: main 39 | public: 40 | T( uCluster &clus ) : uBaseTask( clus ) {} 41 | }; // T 42 | 43 | int main() { 44 | uCluster clus( "clus" ); 45 | osacquire( cout ) << "cluster: " << &clus << endl; 46 | uProcessor p; 47 | T t( clus ); 48 | osacquire( cout ) << "over" << endl; 49 | p.setCluster( clus ); 50 | sleep( 1 ); 51 | osacquire( cout ) << "back" << endl; 52 | p.setCluster( uThisCluster() ); 53 | sleep( 10 ); 54 | osacquire( cout ) << "over" << endl; 55 | p.setCluster( clus ); 56 | osacquire( cout ) << "finish" << endl; 57 | } // main 58 | 59 | // Local Variables: // 60 | // compile-command: "u++ TimeoutProcessor.cc" // 61 | // End: // 62 | -------------------------------------------------------------------------------- /source/src/examples/UncaughtException.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2010 4 | // 5 | // UncaughtException.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Sun Jul 18 11:14:42 2010 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Wed Apr 20 23:01:58 2022 11 | // Update Count : 8 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using namespace std; 29 | 30 | _Task T1 { 31 | void main() { 32 | for( ;; ) { 33 | _Accept( ~T1 ) break; 34 | try { 35 | throw 1; 36 | } catch( int ) { 37 | } // try 38 | } // for 39 | } // T1::main 40 | }; // T1 41 | 42 | _Task T2 { 43 | void main() { 44 | for( ;; ) { 45 | _Accept( ~T2 ) break; 46 | assert( ! std::__U_UNCAUGHT_EXCEPTION__() ); 47 | yield(); 48 | } // for 49 | } // T2::main 50 | }; // T2 51 | 52 | int main() { 53 | T1 t1; 54 | T2 t2; 55 | sleep( 5 ); 56 | cout << "Successful completion" << endl; 57 | } // main 58 | -------------------------------------------------------------------------------- /source/src/examples/uCalibrate.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // uCalibrate.cc -- Calibrate the number of iterations of a set piece of code to produce a 100 microsecond delay. 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Fri Aug 16 14:12:08 1991 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Apr 24 18:21:30 2022 11 | // Update Count : 43 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include 28 | using std::cout; 29 | using std::endl; 30 | 31 | #define TIMES 5'000'000'000LL //' cannot be larger or overflow occurs 32 | 33 | int main() { 34 | uTime start = uClock::getCPUTime(); 35 | for ( volatile unsigned long long int i = 1; i <= TIMES; i += 1 ) { 36 | } // for 37 | cout << "#define ITERATIONS_FOR_100USECS " << 100000LL * TIMES / ( (uClock::getCPUTime() - start).nanoseconds() ) << endl; 38 | } // main 39 | 40 | // Local Variables: // 41 | // compile-command: "u++ uCalibrate.cc" // 42 | // End: // 43 | -------------------------------------------------------------------------------- /source/src/examples/uContext.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // uContext.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Jul 7 13:08:01 1994 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Apr 24 17:02:10 2022 11 | // Update Count : 29 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | // WARNING: Do not use cout/cerr/printf in save or restore as they cause a recursive context switch or deadlock. 29 | 30 | class uCoProcessorCxt1 : public uContext { 31 | static int uUniqueKey; 32 | #define savemsg1 "uCoProcessorCxt1::save\n" 33 | #define restoremsg1 "uCoProcessorCxt1::restore\n" 34 | public: 35 | uCoProcessorCxt1() : uContext( &uUniqueKey ) {}; 36 | void save() { 37 | write( 1, savemsg1, sizeof( savemsg1 ) - 1 ); 38 | } 39 | void restore() { 40 | write( 1, restoremsg1, sizeof( restoremsg1 ) - 1 ); 41 | } 42 | }; // uCoProcessorCxt1 43 | int uCoProcessorCxt1::uUniqueKey = 0; 44 | 45 | 46 | class uCoProcessorCxt2 : public uContext { 47 | #define savemsg2 "uCoProcessorCxt2::save\n" 48 | #define restoremsg2 "uCoProcessorCxt2::restore\n" 49 | public: 50 | void save() { 51 | write( 1, savemsg2, sizeof( savemsg2 ) - 1 ); 52 | } 53 | void restore() { 54 | write( 1, restoremsg2, sizeof( restoremsg2 ) - 1 ); 55 | } 56 | }; // uCoProcessorCxt2 57 | 58 | 59 | int main() { 60 | uCoProcessorCxt1 cpCxt11, cpCxt12; 61 | uCoProcessorCxt2 cpCxt21, cpCxt22; 62 | 63 | for ( int i = 0; i < 5; i += 1 ) { 64 | yield(); 65 | } // for 66 | } // main 67 | 68 | // Local Variables: // 69 | // compile-command: "u++ -O uContext.cc" // 70 | // End: // 71 | -------------------------------------------------------------------------------- /source/src/kernel/assert.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2009 4 | // 5 | // assert.h -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Dec 10 20:40:07 2009 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Tue Apr 25 13:57:39 2023 11 | // Update Count : 54 12 | // 13 | 14 | // This include file is not idempotent, so there is no guard. 15 | 16 | extern "C" void __assert_fail( const char *__assertion, const char *__file, unsigned int __line, const char *__function ) 17 | __THROW __attribute__ ((__noreturn__)); 18 | extern "C" void __assert_perror_fail( int __errnum, const char *__file, unsigned int __line, const char *__function ) 19 | __THROW __attribute__ ((__noreturn__)); 20 | extern "C" void __assert( const char *__assertion, const char *__file, int __line ) 21 | __THROW __attribute__ ((__noreturn__)); 22 | 23 | #ifdef NDEBUG 24 | #define assert( expr ) ((void)0) 25 | #else 26 | #include // abort 27 | #include // STDERR_FILENO 28 | #include 29 | 30 | #define __STRINGIFY__(str) #str 31 | #define __VSTRINGIFY__(str) __STRINGIFY__(str) 32 | 33 | #define assert( expr ) \ 34 | if ( ! ( expr ) ) { \ 35 | int retcode __attribute__(( unused )); \ 36 | uDebugWrite( STDERR_FILENO, __FILE__ ":" __VSTRINGIFY__(__LINE__) ": Assertion \"" __VSTRINGIFY__(expr) "\" failed.\n", \ 37 | sizeof( __FILE__ ":" __VSTRINGIFY__(__LINE__) ": Assertion \"" __VSTRINGIFY__(expr) "\" failed.\n" ) - 1 ); \ 38 | abort(); \ 39 | } 40 | #endif // NDEBUG 41 | 42 | 43 | // Local Variables: // 44 | // compile-command: "make install" // 45 | // End: // 46 | -------------------------------------------------------------------------------- /source/src/kernel/uAlign.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // uAlign.h -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Sat Dec 18 22:08:40 1993 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Aug 28 20:47:56 2022 11 | // Update Count : 57 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | // Minimum size used to align memory boundaries for memory allocations. Minimum size must be >= 32 | // sizeof(uHeapManager::uStorage). 33 | 34 | #define uAlign() (__BIGGEST_ALIGNMENT__) 35 | 36 | // Check for power of 2 37 | 38 | static inline __attribute__((always_inline)) bool uPow2( unsigned long int value ) { 39 | // clears all bits below value, rounding value down to the next lower multiple of value 40 | return (value & (value - 1)) == 0; 41 | } // uPow2 42 | 43 | 44 | // Returns value aligned at the floor of align. 45 | 46 | static inline __attribute__((always_inline)) unsigned long int uFloor( unsigned long int value, unsigned long int align ) { 47 | assert( uPow2( align ) ); 48 | // clears all bits above or equal to align, getting (value % align), the phase of value with regards to align 49 | return value & -align; 50 | } // uFloor 51 | 52 | 53 | // Returns value aligned at the ceiling of align. 54 | 55 | static inline __attribute__((always_inline)) unsigned long int uCeiling( unsigned long int value, unsigned long int align ) { 56 | assert( uPow2( align ) ); 57 | // "negate, round down, negate" is the same as round up 58 | return -uFloor( -value, align ); 59 | } // uCeiling 60 | 61 | 62 | // Local Variables: // 63 | // compile-command: "make install" // 64 | // End: // 65 | -------------------------------------------------------------------------------- /source/src/kernel/uBootTask.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // uBootTask.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Apr 28 13:31:12 1994 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Tue Apr 25 15:14:16 2023 11 | // Update Count : 149 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #define __U_KERNEL__ 29 | #include 30 | #include 31 | 32 | 33 | namespace UPP { 34 | void uBootTask::main() { 35 | // NEVER INVOKED BECAUSE BOOT TASK IS ALREADY RUNNING USING THE UNIX THREAD. 36 | } // uBootTask::main 37 | 38 | 39 | uBootTask::uBootTask() : uBaseTask( *uKernelModule::systemCluster ) { 40 | // SKULLDUGGERY: Explicitly make this task look like the currently executing task. 41 | 42 | // No concurrency, so safe to make direct call through TLS pointer. 43 | uKernelModule::uKernelModuleBoot.activeTask = this; 44 | 45 | // SKULLDUGGERY: Remove "main" from the suspend stack so it is never executed. This trick makes this task into a 46 | // pseudo-task to execute the global constructor and destructor lists. 47 | 48 | uSerialInstance.acceptSignalled.drop(); 49 | 50 | // SKULLDUGGERY: Because this task has been removed from the suspend stack, it is not woken by 51 | // uSerialConstructor so do this manually by putting the task on the ready queue. 52 | 53 | wake(); 54 | } // uBootTask::uBootTask 55 | 56 | 57 | uBootTask::~uBootTask() { 58 | // SKULLDUGGERY: Since this task does not have a "main" routine, some of its termination code must be performed 59 | // manually. 60 | 61 | notHalted_ = false; 62 | } // uBootTask::~uBootTask 63 | } // UPP 64 | 65 | 66 | // Local Variables: // 67 | // compile-command: "make install" // 68 | // End: // 69 | -------------------------------------------------------------------------------- /source/src/kernel/uBootTask.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // uBootTask.h -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Apr 28 11:54:04 1994 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sat Aug 20 07:36:22 2022 11 | // Update Count : 35 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | namespace UPP { 32 | _Task uBootTask { 33 | friend class uKernelBoot; // access: new 34 | 35 | void main(); 36 | public: 37 | uBootTask(); 38 | ~uBootTask(); 39 | }; // uBootTask 40 | } // UPP 41 | 42 | 43 | // Local Variables: // 44 | // compile-command: "make install" // 45 | // End: // 46 | -------------------------------------------------------------------------------- /source/src/kernel/uDebug.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // uDebug.h -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Sat Dec 18 12:56:10 1993 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sat Apr 23 11:37:18 2022 11 | // Update Count : 59 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | #ifdef __U_DEBUG_H__ 31 | #undef uDEBUGPRT 32 | #define uDEBUGPRT( stmt ) stmt 33 | #else 34 | #define uDEBUGPRT( stmt ) 35 | #endif // __U_DEBUG_H__ 36 | 37 | extern "C" void uDebugWrite( int fd, const char *buffer, int len ); 38 | extern "C" void uDebugAcquire(); 39 | extern "C" void uDebugRelease(); 40 | extern "C" int uDebugPrt( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )); 41 | extern "C" int uDebugPrt2( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )); 42 | extern "C" int uDebugPrtBuf( char buffer[], const char fmt[], ... ) __attribute__(( format (printf, 2, 3) )); 43 | extern "C" int uDebugPrtBuf2( int fd, char buffer[], int buflen, const char fmt[], ... ) __attribute__(( format (printf, 4, 5) )); 44 | 45 | 46 | // Local Variables: // 47 | // compile-command: "make install" // 48 | // End: // 49 | -------------------------------------------------------------------------------- /source/src/kernel/uDefaultPreemption.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // uDefaultPreemption.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Fri Feb 11 21:26:22 1994 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Apr 3 09:38:17 2022 11 | // Update Count : 14 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #include 29 | 30 | 31 | // Must be a separate translation unit so that an application can redefine this routine and the loader does not link 32 | // this routine from the uC++ standard library. 33 | 34 | 35 | unsigned int uDefaultPreemption() { 36 | return __U_DEFAULT_PREEMPTION__; 37 | } // uDefaultPreemption 38 | 39 | 40 | // Local Variables: // 41 | // compile-command: "make install" // 42 | // End: // 43 | -------------------------------------------------------------------------------- /source/src/kernel/uDefaultProcessors-OpenMP.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Richard C. Bilson 2006 4 | // 5 | // uDefaultProcessors-OpenMP.cc -- 6 | // 7 | // Author : Richard C. Bilson 8 | // Created On : Tue Aug 8 16:53:43 2006 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Jul 30 09:17:04 2023 11 | // Update Count : 13 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #include 29 | #include // sysconf 30 | #include // getenv, atoi 31 | 32 | 33 | // Must be a separate translation unit so that an application can redefine this routine and the loader does not link 34 | // this routine from the uC++ standard library. 35 | 36 | 37 | // OpenMP creates one kernel thread for each physical processor by default, which can be overridden by specifying the 38 | // OMP_NUM_THREADS environment variable. 39 | 40 | unsigned int uDefaultProcessors() { 41 | unsigned int nprocs = 0; 42 | const char * value = getenv( "OMP_NUM_THREADS" ); // OMP_NUM_THREADS=value 43 | 44 | if ( value != nullptr ) { 45 | nprocs = atoi( value ); 46 | } else { 47 | nprocs = sysconf( _SC_NPROCESSORS_ONLN ); 48 | } // if 49 | return __U_DEFAULT_USER_PROCESSORS__ > nprocs ? __U_DEFAULT_USER_PROCESSORS__ : nprocs; 50 | } // uDefaultProcessors 51 | 52 | 53 | // Local Variables: // 54 | // compile-command: "make install" // 55 | // End: // 56 | -------------------------------------------------------------------------------- /source/src/kernel/uDefaultProcessors.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Richard C. Bilson 2006 4 | // 5 | // uDefaultProcessors.cc -- 6 | // 7 | // Author : Richard C. Bilson 8 | // Created On : Tue Aug 8 16:53:43 2006 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Apr 3 09:39:05 2022 11 | // Update Count : 5 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #include 29 | 30 | 31 | // Must be a separate translation unit so that an application can redefine this routine and the loader does not link 32 | // this routine from the uC++ standard library. 33 | 34 | 35 | unsigned int uDefaultProcessors() { 36 | return __U_DEFAULT_USER_PROCESSORS__; 37 | } // uDefaultProcessors 38 | 39 | 40 | // Local Variables: // 41 | // compile-command: "make install" // 42 | // End: // 43 | -------------------------------------------------------------------------------- /source/src/kernel/uDefaultSpin.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // uDefaultSpin.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Fri Feb 11 21:23:10 1994 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Apr 3 09:39:12 2022 11 | // Update Count : 14 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #include 29 | 30 | 31 | // Must be a separate translation unit so that an application can redefine this routine and the loader does not link 32 | // this routine from the uC++ standard library. 33 | 34 | 35 | unsigned int uDefaultSpin() { 36 | return __U_DEFAULT_SPIN__; 37 | } // uDefaultSpin 38 | 39 | 40 | // Local Variables: // 41 | // compile-command: "make install" // 42 | // End: // 43 | -------------------------------------------------------------------------------- /source/src/kernel/uDefaultStackSize.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // uDefaultStackSize.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Fri Feb 11 21:25:14 1994 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Apr 3 09:39:20 2022 11 | // Update Count : 14 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #include 29 | 30 | 31 | // Must be a separate translation unit so that an application can redefine this routine and the loader does not link 32 | // this routine from the uC++ standard library. 33 | 34 | 35 | unsigned int uDefaultStackSize() { 36 | return __U_DEFAULT_STACK_SIZE__; 37 | } // uDefaultStackSize 38 | 39 | 40 | // Local Variables: // 41 | // compile-command: "make install" // 42 | // End: // 43 | -------------------------------------------------------------------------------- /source/src/kernel/uFloat.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // uFloat.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Mon Oct 10 08:30:46 1994 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Tue Apr 25 15:21:00 2023 11 | // Update Count : 43 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #define __U_KERNEL__ 29 | #include 30 | 31 | 32 | #ifdef __U_FLOATINGPOINTDATASIZE__ 33 | uFloatingPointContext::uFloatingPointContext() : uContext( &uniqueKey ) { 34 | } // uFloatingPointContext::uFloatingPointContext 35 | #endif // __U_FLOATINGPOINTDATASIZE__ 36 | 37 | void uFloatingPointContext::save() { 38 | #if defined( __i386__ ) 39 | // saved by caller 40 | #elif defined( __x86_64__ ) 41 | // saved by caller 42 | #elif defined( __arm_64__ ) 43 | // saved by context switch 44 | #else 45 | #error uC++ : internal error, unsupported architecture 46 | #endif 47 | } // uFloatingPointContext::save 48 | 49 | 50 | void uFloatingPointContext::restore() { 51 | #if defined( __i386__ ) 52 | // restored by caller 53 | #elif defined( __x86_64__ ) 54 | // restored by caller 55 | #elif defined( __arm_64__ ) 56 | // restored by context switch 57 | #else 58 | #error uC++ : internal error, unsupported architecture 59 | #endif 60 | } // uFloatingPointContext::restore 61 | 62 | 63 | // Local Variables: // 64 | // compile-command: "make install" // 65 | // End: // 66 | -------------------------------------------------------------------------------- /source/src/kernel/uHeapLmmm.h: -------------------------------------------------------------------------------- 1 | // 2 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 3 | // 4 | // uHeapLmmm.h -- 5 | // 6 | // Author : Peter A. Buhr 7 | // Created On : Wed Jul 20 00:07:05 1994 8 | // Last Modified By : Peter A. Buhr 9 | // Last Modified On : Tue Jul 2 22:39:16 2024 10 | // Update Count : 536 11 | // 12 | // This library is free software; you can redistribute it and/or modify it 13 | // under the terms of the GNU Lesser General Public License as published by the 14 | // Free Software Foundation; either version 2.1 of the License, or (at your 15 | // option) any later version. 16 | // 17 | // This library is distributed in the hope that it will be useful, but WITHOUT 18 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 20 | // for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public License 23 | // along with this library. 24 | // 25 | 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | extern "C" { 32 | // New allocation operations. 33 | void * aalloc( size_t dim, size_t elemSize ) __THROW __attribute__ ((malloc)); 34 | void * resize( void * oaddr, size_t size ) __THROW __attribute__ ((malloc)); 35 | void * amemalign( size_t align, size_t dim, size_t elemSize ) __THROW __attribute__ ((malloc)); 36 | void * cmemalign( size_t align, size_t dim, size_t elemSize ) __THROW __attribute__ ((malloc)); 37 | size_t malloc_alignment( void * addr ) __THROW; 38 | bool malloc_zero_fill( void * addr ) __THROW; 39 | size_t malloc_size( void * addr ) __THROW; 40 | int malloc_stats_fd( int fd ) __THROW; 41 | size_t malloc_expansion(); // heap expansion size (bytes) 42 | size_t malloc_mmap_start(); // crossover allocation size from sbrk to mmap 43 | size_t malloc_unfreed(); // heap unfreed size (bytes) 44 | void malloc_stats_clear(); // clear heap statistics 45 | void heap_stats(); // print thread-heap statistics 46 | } // extern "C" 47 | 48 | // New allocation operations. 49 | void * resize( void * oaddr, size_t nalign, size_t size ) __THROW; 50 | void * realloc( void * oaddr, size_t nalign, size_t size ) __THROW; 51 | void * reallocarray( void * oaddr, size_t nalign, size_t dim, size_t elemSize ) __THROW; 52 | 53 | 54 | // Local Variables: // 55 | // mode: c++ // 56 | // tab-width: 4 // 57 | // compile-command: "make install" // 58 | // End: // 59 | -------------------------------------------------------------------------------- /source/src/kernel/uMainStackSize.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1996 4 | // 5 | // uMainStackSize.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Wed May 15 23:28:39 1996 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Apr 3 09:47:06 2022 11 | // Update Count : 10 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #include 29 | 30 | 31 | // Must be a separate translation unit so that an application can redefine this routine and the loader does not link 32 | // this routine from the uC++ standard library. 33 | 34 | 35 | unsigned int uMainStackSize() { 36 | return __U_DEFAULT_MAIN_STACK_SIZE__; 37 | } // uMainStackSize 38 | 39 | 40 | // Local Variables: // 41 | // compile-command: "make install" // 42 | // End: // 43 | -------------------------------------------------------------------------------- /source/src/kernel/uProcessor.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // uProcessor.h -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu May 26 09:36:12 1994 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Apr 3 10:12:30 2022 11 | // Update Count : 54 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | //######################### uProcessorTask ######################### 32 | 33 | 34 | _Task uProcessorTask { 35 | friend class uProcessor; // access: setPreemption 36 | 37 | uProcessor &processor; // associated processor 38 | uCondition result; 39 | 40 | 41 | unsigned int preemption; // communication: setPreemption 42 | uCluster *cluster; // communication: setCluster 43 | 44 | void main(); 45 | _Mutex void setPreemption( unsigned int ms ); 46 | _Mutex void setCluster( uCluster &cluster ); 47 | 48 | uProcessorTask( uCluster &cluster, uProcessor &processor ); 49 | ~uProcessorTask(); 50 | public: 51 | }; // uProcessorTask 52 | 53 | 54 | // Local Variables: // 55 | // compile-command: "make install" // 56 | // End: // 57 | -------------------------------------------------------------------------------- /source/src/kernel/uStatistics.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2009 4 | // 5 | // uStatistics.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Fri Apr 10 17:09:04 2009 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Fri Apr 10 17:13:53 2009 11 | // Update Count : 1 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | // Must be a separate translation unit so that an application can redefine this routine and the loader does not link 29 | // this routine from the uC++ standard library. 30 | 31 | 32 | void uStatistics() { 33 | } // uStatistics 34 | 35 | 36 | // Local Variables: // 37 | // compile-command: "make install" // 38 | // End: // 39 | -------------------------------------------------------------------------------- /source/src/kernel/uSwitch-m68k.S: -------------------------------------------------------------------------------- 1 | # -*- Mode: Asm -*- 2 | # 3 | # uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1995 4 | # 5 | # uSwitch-m68k.s -- 6 | # 7 | # Author : Peter A. Buhr 8 | # Created On : Mon Jan 2 20:55:37 1995 9 | # Last Modified By : Peter A. Buhr 10 | # Last Modified On : Mon Jul 21 21:17:54 2003 11 | # Update Count : 13 12 | # 13 | # This library is free software; you can redistribute it and/or modify it 14 | # under the terms of the GNU Lesser General Public License as published by the 15 | # Free Software Foundation; either version 2.1 of the License, or (at your 16 | # option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, but WITHOUT 19 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | # for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public License 24 | # along with this library. 25 | # 26 | 27 | # This context switch routine depends on the fact that the stack of a new 28 | # thread has been set up to look like the thread has saved its context in 29 | # the normal manner. 30 | # 31 | # void uSwitch( uMachContext *to, uMachContext *from ); 32 | 33 | .text 34 | .even 35 | .globl uSwitch 36 | uSwitch: 37 | 38 | | Copy the "from" context argument from the stack to register a0 39 | 40 | movel sp@(8),a0 41 | 42 | | Save volatile registers (d2-d7,a2-a5,fp) on the stack. 43 | 44 | moveml #0x3f3e,sp@- 45 | 46 | | Save stack pointer in the "from" area at offset 0. 47 | 48 | movel sp,a0@ 49 | 50 | | Copy the "to" context argument from the stack to register a0 51 | 52 | movel sp@(48),a0 53 | 54 | | Load stack pointer from the "to" area at offset 0. 55 | 56 | movel a0@,sp 57 | 58 | | Load volatile registers (d2-d7,a2-a5,fp) from the stack. 59 | 60 | moveml sp@+,#0x7cfc 61 | 62 | | Return to thread. 63 | 64 | rts 65 | 66 | ## Local Variables: ## 67 | ## compile-command: "make install" ## 68 | ## End: ## 69 | -------------------------------------------------------------------------------- /source/src/kernel/uSystemTask.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1998 4 | // 5 | // uSystemTask.h -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Mon Jun 22 15:23:25 1998 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Apr 3 10:51:23 2022 11 | // Update Count : 25 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | _Task uSystemTask { 32 | friend _Task UPP::uPthread; // access: pthreadDetachEnd 33 | 34 | uBaseTask *victim; // communication 35 | 36 | // pthread 37 | 38 | _Mutex void pthreadDetachEnd( uBaseTask &victim ); 39 | 40 | void main(); 41 | public: 42 | uSystemTask(); 43 | ~uSystemTask(); 44 | void reaper( uBaseTask &victim ); 45 | }; // uSystemTask 46 | 47 | 48 | // Local Variables: // 49 | // compile-command: "make install" // 50 | // End: // 51 | -------------------------------------------------------------------------------- /source/src/kernel/write.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | __typeof__( ::write ) *Rwrite; 6 | 7 | extern "C" ssize_t write( int fd, const void *buf, size_t count ) { 8 | ssize_t retcode; 9 | if ( ! Rwrite) 10 | Rwrite = (__typeof__(write) *)dlvsym(RTLD_NEXT, "write", "GLIBC_2.2.5"); 11 | 12 | for ( ;; ) { 13 | retcode = Rwrite( fd, buf, count ); // call the real routine 14 | if ( retcode != -1 || errno != EINTR ) break; // timer interrupt ? 15 | } // for 16 | return retcode; 17 | } // write 18 | 19 | // g++ -shared -ldl -fPIC -g write.cc -o libwrite.so 20 | // http://www.jayconrod.com/cgi/view_post.py?23 21 | -------------------------------------------------------------------------------- /source/src/library/Makefile: -------------------------------------------------------------------------------- 1 | ## Define the appropriate configuration variables. 2 | 3 | PACKAGE = /u0/usystem/software/u++-7.0.0 4 | 5 | ## Include the architecture dependent definitions. 6 | 7 | include ${PACKAGE}/CONFIG 8 | 9 | ## Define the path names of important directories. 10 | 11 | SRCDIR = ${PACKAGE}/src/library 12 | 13 | ## Define some of the tools. 14 | 15 | include ${PACKAGE}/src/MakeTools 16 | 17 | ## Define the C++ source files. 18 | 19 | LIBSRC = ${addprefix ${SRCDIR}/, ${addsuffix .cc, \ 20 | uFile \ 21 | uPoll \ 22 | uSocket \ 23 | uDefaultExecutorProcessors \ 24 | uDefaultExecutorWorkers \ 25 | uDefaultExecutorRQueues \ 26 | uDefaultExecutorSepClus \ 27 | uDefaultExecutorAffinity \ 28 | uFuture \ 29 | uCobegin \ 30 | uActor \ 31 | uPRNG \ 32 | pthread \ 33 | Unix \ 34 | } } 35 | 36 | LIBSRC-D = ${LIBSRC} 37 | ifeq (${MULTI},TRUE) 38 | LIBSRC-M = ${LIBSRC} 39 | LIBSRC-M-D = ${LIBSRC} 40 | endif 41 | 42 | ## Define the header files 43 | 44 | HEADERS = ostream fstream mutex shared_mutex type_traits bits/std_mutex.h bits/unique_lock.h ${shell ls *.h} 45 | 46 | ## Define which libraries should be built. 47 | 48 | LIB = ${LIBDIR}/uLibrary.a 49 | LIB-D = ${LIBDIR}/uLibrary-d.a 50 | ifeq (${MULTI},TRUE) 51 | LIB-M = ${LIBDIR}/uLibrary-m.a 52 | LIB-M-D = ${LIBDIR}/uLibrary-m-d.a 53 | endif 54 | 55 | ## Define the things that can be defined based upon previous definitions. 56 | 57 | include ${PACKAGE}/src/MakeDefinitions 58 | 59 | ## Define the specific recipes. 60 | 61 | all : ${LIBRARIES} 62 | 63 | INSTALLFILES = ${addprefix ${INSTALLLIBDIR}/, ${notdir ${LIBRARIES}}} ${addprefix ${INSTALLINCDIR}/, ${HEADERS}} 64 | 65 | install : all ${INSTALLFILES} 66 | 67 | ## Handle special include-file names. 68 | 69 | ${SRCDIR}/ostream: ${SRCDIR}/ostream.h 70 | cp ${SRCDIR}/ostream.h ${SRCDIR}/ostream 71 | 72 | ${SRCDIR}/fstream: ${SRCDIR}/fstream.h 73 | cp ${SRCDIR}/fstream.h ${SRCDIR}/fstream 74 | 75 | ## Define default dependencies and recipes for object files. 76 | 77 | include ${PACKAGE}/src/MakeRecipes 78 | 79 | ## Include the dependencies for object files and libraries. 80 | 81 | -include ${DEPENDS} 82 | 83 | ## Create directories (TEMPORARY: fixed in gmake 3.80} 84 | 85 | _xxx1 := ${shell mkdir -p ${LIBDIR} ${OBJDIR}} 86 | 87 | ifeq (${MAKECMDGOALS},install) 88 | _xxx2 := ${shell mkdir -p ${INSTALLLIBDIR} ${INSTALLINCDIR} ${INSTALLINCDIR}/bits} 89 | endif 90 | 91 | ## Local Variables: ## 92 | ## compile-command: "make install" ## 93 | ## End: ## 94 | -------------------------------------------------------------------------------- /source/src/library/Unix.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2002 4 | // 5 | // Unix.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Mon Dec 2 22:46:18 2002 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Tue Apr 19 11:22:29 2022 11 | // Update Count : 26 12 | // 13 | 14 | #define __U_KERNEL__ 15 | #include 16 | //#include 17 | 18 | 19 | extern "C" unsigned int sleep( unsigned int sec ) { 20 | _Timeout( uDuration( sec, 0 ) ); 21 | return 0; 22 | } // sleep 23 | 24 | 25 | extern "C" int usleep( unsigned int usec ) { 26 | _Timeout( uDuration( 0, usec ) ); 27 | return 0; 28 | } // usleep 29 | 30 | 31 | extern "C" unsigned int alarm( unsigned int /* sec */ ) __THROW { 32 | abort( "alarm : not implemented" ); 33 | return 0; 34 | } // alarm 35 | 36 | 37 | // Local Variables: // 38 | // compile-command: "make install" // 39 | // End: // 40 | -------------------------------------------------------------------------------- /source/src/library/bits/std_mutex.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2014 4 | // 5 | // std_mutex.h -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Fri May 13 12:23:47 2016 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Wed Jan 4 12:35:32 2023 11 | // Update Count : 10 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | // This include file uses the uC++ keyword _Mutex as a template parameter name. 28 | // The name is changed only for the include file. 29 | 30 | #if ! defined( _Mutex ) // nesting ? 31 | #define _Mutex Mutex_ // make keyword an identifier 32 | #define __U_STD_MUTEX_H__ 33 | #endif 34 | 35 | #include_next 36 | 37 | #if defined( _Mutex ) && defined( __U_STD_MUTEX_H__ ) // reset only if set 38 | #undef __U_STD_MUTEX_H__ 39 | #undef _Mutex 40 | #endif 41 | 42 | // Local Variables: // 43 | // compile-command: "make install" // 44 | // End: // 45 | -------------------------------------------------------------------------------- /source/src/library/bits/unique_lock.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2023 4 | // 5 | // unique_lock.h -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Wed Jan 4 11:37:42 2023 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Wed Jan 4 15:58:32 2023 11 | // Update Count : 2 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | // This include file uses the uC++ keyword _Mutex as a template parameter name. 28 | // The name is changed only for the include file. 29 | 30 | #if ! defined( _Mutex ) // nesting ? 31 | #define _Mutex Mutex_ // make keyword an identifier 32 | #define __U_UNIQUE_LOCK_H__ 33 | #endif 34 | 35 | #include_next 36 | 37 | #if defined( _Mutex ) && defined( __U_UNIQUE_LOCK_H__ ) // reset only if set 38 | #undef __U_UNIQUE_LOCK_H__ 39 | #undef _Mutex 40 | #endif 41 | 42 | // Local Variables: // 43 | // compile-command: "make install" // 44 | // End: // 45 | -------------------------------------------------------------------------------- /source/src/library/mutex: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2014 4 | // 5 | // mutex -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Jul 17 17:56:08 2014 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Wed Jan 4 12:36:17 2023 11 | // Update Count : 12 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | // This include file uses the uC++ keyword _Mutex as a template parameter name. 28 | // The name is changed only for the include file. 29 | 30 | #if ! defined( _Mutex ) // nesting ? 31 | #define _Mutex Mutex_ // make keyword an identifier 32 | #define __U_MUTEX_H__ 33 | #endif 34 | 35 | #include_next 36 | 37 | #if defined( _Mutex ) && defined( __U_MUTEX_H__ ) // reset only if set 38 | #undef __U_MUTEX_H__ 39 | #undef _Mutex 40 | #endif 41 | 42 | // Local Variables: // 43 | // compile-command: "make install" // 44 | // End: // 45 | -------------------------------------------------------------------------------- /source/src/library/shared_mutex: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2023 4 | // 5 | // shared_mutex -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Wed Jan 4 11:43:20 2023 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Wed Jan 4 12:32:14 2023 11 | // Update Count : 2 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | // This include file uses the uC++ keyword _Mutex as a template parameter name. 28 | // The name is changed only for the include file. 29 | 30 | #if ! defined( _Mutex ) // nesting ? 31 | #define _Mutex Mutex_ // make keyword an identifier 32 | #define __U_SHARED_MUTEX_H__ 33 | #endif 34 | 35 | #include_next 36 | 37 | #if defined( _Mutex ) && defined( __U_SHARED_MUTEX_H__ ) // reset only if set 38 | #undef __U_SHARED_MUTEX_H__ 39 | #undef _Mutex 40 | #endif 41 | 42 | // Local Variables: // 43 | // compile-command: "make install" // 44 | // End: // 45 | -------------------------------------------------------------------------------- /source/src/library/type_traits: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2023 4 | // 5 | // type_traits -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Wed Jan 4 11:44:16 2023 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Wed Jan 4 12:33:42 2023 11 | // Update Count : 2 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | // This include file uses the uC++ keyword _Else as a template parameter name. 28 | // The name is changed only for the include file. 29 | 30 | #if ! defined( _Else ) // nesting ? 31 | #define _Else Else_ // make keyword an identifier 32 | #define __U_TYPE_TRAITS_H__ 33 | #endif 34 | 35 | #include_next 36 | 37 | #if defined( _Else ) && defined( __U_TYPE_TRAITS_H__ ) // reset only if set 38 | #undef __U_TYPE_TRAITS_H__ 39 | #undef _Else 40 | #endif 41 | 42 | // Local Variables: // 43 | // compile-command: "make install" // 44 | // End: // 45 | -------------------------------------------------------------------------------- /source/src/library/uActor.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Thierry Delisle 2016 4 | // 5 | // uActor.cc -- 6 | // 7 | // Author : Peter A. Buhr and Thierry Delisle 8 | // Created On : Mon Nov 14 22:41:44 2016 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Fri Mar 10 10:41:58 2023 11 | // Update Count : 116 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #define __U_KERNEL__ 28 | #include 29 | #include 30 | #include 31 | using namespace std; 32 | 33 | uExecutor * uActor::executor_ = nullptr; // executor for all actors 34 | bool uActor::executorp = false; // executor passed to start member 35 | uSemaphore uActor::wait_( 0 ); // wait for all actors to be destroyed 36 | size_t uActor::actors_ = 0; // number of actor objects in system 37 | uActor::StartMsg uActor::startMsg; // start actor 38 | uActor::StopMsg uActor::stopMsg; // terminate actor 39 | uActor::UnhandledMsg uActor::unhandledMsg; // tell error 40 | 41 | void uActor::TraceMsg::print() { 42 | enum { PerLine = 8 }; 43 | TraceMsg::Hop * route; 44 | 45 | cout << "message " << this 46 | << " source:" << hops.head() 47 | << " cursor (node:" << cursor << ", actor:" << (cursor ? cursor->actor : nullptr) << ')' 48 | << endl << " trace "; 49 | size_t cnt = 0; 50 | for ( uQueueIter iter(cursor); iter >> route; cnt += 1 ) { // print route 51 | if ( cnt != 0 && cnt % PerLine == 0 ) cout << endl << "\t"; 52 | cout << route->actor; 53 | // HACK, know queue is circular 54 | if ( route->getnext() != route && (cnt + 1) % PerLine != 0 ) cout << " "; 55 | } // for 56 | cout << endl; 57 | } // uActor::TraceMsg::print 58 | 59 | 60 | // Local Variables: // 61 | // compile-command: "make install" // 62 | // End: // 63 | -------------------------------------------------------------------------------- /source/src/library/uCobegin.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Thierry Delisle 2020 4 | // 5 | // uCobegin.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Sun Oct 11 15:53:22 2020 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Tue Jan 17 09:29:33 2023 11 | // Update Count : 4 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #define __U_KERNEL__ 28 | #include 29 | #include 30 | 31 | void uCobegin( std::initializer_list< std::function< void ( unsigned int ) >> funcs ) { 32 | unsigned int uLid = 0; 33 | _Task Runner { 34 | typedef std::function Func; // function type 35 | unsigned int parm; // local thread lid 36 | Func f; // function to run for each lid 37 | 38 | void main() { f( parm ); } 39 | public: 40 | Runner( unsigned int parm, Func f ) : parm( parm ), f( f ) {} 41 | }; // Runner 42 | 43 | const unsigned int size = funcs.size(); 44 | uNoCtor< Runner > * runners = new uNoCtor< Runner >[size]; // do not use up task stack 45 | 46 | for ( auto f : funcs ) { runners[uLid].ctor( uLid, f ); uLid += 1; } 47 | delete [] runners; 48 | } // uCobegin 49 | 50 | 51 | // Local Variables: // 52 | // compile-command: "make install" // 53 | // End: // 54 | -------------------------------------------------------------------------------- /source/src/library/uDefaultExecutor.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1997 4 | // 5 | // uDefaultExecutor.h -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Jan 2 20:45:32 2020 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Jan 29 21:10:28 2023 11 | // Update Count : 10 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | #include // size_t 31 | 32 | // Define the default number of processors created in the executor. Must be greater than 0. 33 | 34 | #define __U_DEFAULT_EXECUTOR_PROCESSORS__ 2 35 | 36 | // Define the default number of threads created in the executor. Must be greater than 0. 37 | 38 | #define __U_DEFAULT_EXECUTOR_WORKERS__ 2 39 | 40 | // Define the default number of executor request-queues (mailboxes) written to by actors and serviced by the 41 | // actor-executor threads. Must be greater than 0. 42 | 43 | #define __U_DEFAULT_EXECUTOR_RQUEUES__ 2 44 | 45 | // Define if executor is created in a separate cluster 46 | 47 | #define __U_DEFAULT_EXECUTOR_SEPCLUS__ false 48 | 49 | // Define affinity for executor kernel threads and the offset from CPU 0 to start binding. -1 implies no affinity. 50 | 51 | #define __U_DEFAULT_EXECUTOR_AFFINITY__ -1 52 | 53 | 54 | extern size_t uDefaultExecutorProcessors(); // kernel threads (processors) servicing executor thread-pool 55 | extern size_t uDefaultExecutorWorkers(); // worker threads servicing executor thread-pool 56 | extern size_t uDefaultExecutorRQueues(); // executor request queues 57 | extern bool uDefaultExecutorSepClus(); // create processors on separate cluster 58 | extern int uDefaultExecutorAffinity(); // affinity and offset (-1 => no affinity, default) 59 | -------------------------------------------------------------------------------- /source/src/library/uDefaultExecutorAffinity.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2017 4 | // 5 | // uDefaultExecutorAffinity.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Jan 2 20:50:47 2020 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Tue Apr 19 11:24:45 2022 11 | // Update Count : 2 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #include 29 | 30 | 31 | // Must be a separate translation unit so that an application can redefine this routine and the loader does not link 32 | // this routine from the uC++ standard library. 33 | 34 | 35 | int uDefaultExecutorAffinity() { 36 | return __U_DEFAULT_EXECUTOR_AFFINITY__; // affinity and CPU offset (-1 => no affinity, default) 37 | } // uDefaultExecutorAffinity 38 | 39 | 40 | // Local Variables: // 41 | // compile-command: "make install" // 42 | // End: // 43 | -------------------------------------------------------------------------------- /source/src/library/uDefaultExecutorProcessors.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Thierry Delisle 2016 4 | // 5 | // uDefaultExecutorProcessors.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Jan 2 20:55:44 2020 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Jan 29 21:02:08 2023 11 | // Update Count : 3 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #include 29 | 30 | 31 | // Must be a separate translation unit so that an application can redefine this routine and the loader does not link 32 | // this routine from the uC++ standard library. 33 | 34 | 35 | size_t uDefaultExecutorProcessors() { 36 | if ( uDefaultExecutorSepClus() ) return __U_DEFAULT_EXECUTOR_PROCESSORS__; 37 | else return __U_DEFAULT_EXECUTOR_PROCESSORS__ - 1; // assume an existing processor so N+1 38 | } // uDefaultExecutorProcessors 39 | 40 | 41 | // Local Variables: // 42 | // compile-command: "make install" // 43 | // End: // 44 | 45 | -------------------------------------------------------------------------------- /source/src/library/uDefaultExecutorRQueues.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2017 4 | // 5 | // uDefaultExecutorRQueues.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Jan 2 20:51:39 2020 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Jan 29 21:02:18 2023 11 | // Update Count : 4 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #include 29 | 30 | 31 | // Must be a separate translation unit so that an application can redefine this routine and the loader does not link 32 | // this routine from the uC++ standard library. 33 | 34 | 35 | size_t uDefaultExecutorRQueues() { 36 | return __U_DEFAULT_EXECUTOR_RQUEUES__; // number of executor request queues 37 | } // uDefaultExecutorRQueues 38 | 39 | 40 | // Local Variables: // 41 | // compile-command: "make install" // 42 | // End: // 43 | -------------------------------------------------------------------------------- /source/src/library/uDefaultExecutorSepClus.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2017 4 | // 5 | // uDefaultExecutorSepClus.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Jan 2 20:57:01 2020 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Wed Apr 20 16:29:35 2022 11 | // Update Count : 2 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #include 29 | 30 | 31 | // Must be a separate translation unit so that an application can redefine this routine and the loader does not link 32 | // this routine from the uC++ standard library. 33 | 34 | 35 | bool uDefaultExecutorSepClus() { 36 | return __U_DEFAULT_EXECUTOR_SEPCLUS__; // create processors on separate cluster 37 | } // uDefaultExecutorSepClus 38 | 39 | 40 | // Local Variables: // 41 | // compile-command: "make install" // 42 | // End: // 43 | -------------------------------------------------------------------------------- /source/src/library/uDefaultExecutorWorkers.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Thierry Delisle 2016 4 | // 5 | // uDefaultExecutorWorkers.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Thu Jan 2 20:58:06 2020 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Jan 29 21:02:29 2023 11 | // Update Count : 4 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #include 29 | 30 | 31 | // Must be a separate translation unit so that an application can redefine this routine and the loader does not link 32 | // this routine from the uC++ standard library. 33 | 34 | 35 | size_t uDefaultExecutorWorkers() { 36 | return __U_DEFAULT_EXECUTOR_WORKERS__; 37 | } // uDefaultExecutorWorkers 38 | 39 | 40 | // Local Variables: // 41 | // compile-command: "make install" // 42 | // End: // 43 | -------------------------------------------------------------------------------- /source/src/library/uFuture.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2019 4 | // 5 | // uFuture.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Mon Jun 3 18:06:58 2019 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Wed Jan 1 15:30:28 2025 11 | // Update Count : 13 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #define __U_KERNEL__ 28 | #include 29 | #include 30 | size_t uExecutor::next = 0; // demultiplex across worker buffers 31 | 32 | uCancelled::uCancelled() { 33 | setMsg( "\nAttempt to deliver a result to a future that is cancelled.\n" 34 | "Possible cause is not checking for cancellation before calling delivery" ); 35 | } // uCancelled::uCancelled 36 | 37 | uDelivery::uDelivery() { 38 | setMsg( "\nAttempt to deliver a result to a future already containing a result.\n" 39 | "Possible cause is forgetting to reset the future before calling delivery." ); 40 | } // uDelivery::uDelivery 41 | 42 | // Local Variables: // 43 | // compile-command: "make install" // 44 | // End: // 45 | -------------------------------------------------------------------------------- /source/src/library/uIOcntl.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // uIOcntl.h -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Tue Mar 29 16:49:48 1994 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Tue Apr 19 11:26:06 2022 11 | // Update Count : 73 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | #include 32 | 33 | 34 | //######################### uIOaccess ######################### 35 | 36 | 37 | struct uIOaccess { 38 | int fd; 39 | uPoll poll; 40 | }; // uIOaccess 41 | 42 | 43 | //######################### uIOClosure ######################### 44 | 45 | 46 | struct uIOClosure { 47 | uIOaccess &access; 48 | int &retcode; 49 | int errno_; 50 | 51 | uIOClosure( uIOaccess &access, int &retcode ) : access( access ), retcode( retcode ) {} 52 | virtual ~uIOClosure() {} 53 | 54 | void wrapper() { 55 | if ( access.poll.getStatus() == uPoll::PollOnDemand ) access.poll.setPollFlag( access.fd ); 56 | for ( ;; ) { 57 | retcode = action(); 58 | if ( retcode != -1 || errno != EINTR ) break; // timer interrupt ? 59 | } // for 60 | if ( retcode == -1 ) errno_ = errno; // preserve errno 61 | if ( access.poll.getStatus() == uPoll::PollOnDemand ) access.poll.clearPollFlag( access.fd ); 62 | } // uIOClosure::wrapper 63 | 64 | bool select( int mask, uDuration *timeout ) { 65 | if ( timeout == nullptr ) { 66 | uThisCluster().select( *this, mask ); 67 | } else { 68 | timeval t = *timeout; // convert to timeval for select 69 | if ( uThisCluster().select( *this, mask, &t ) == 0 ) { // timeout ? 70 | return false; 71 | } // if 72 | } // if 73 | return true; 74 | } // uIOClosure::select 75 | 76 | virtual int action() = 0; 77 | }; // uIOClosure 78 | 79 | 80 | // Local Variables: // 81 | // compile-command: "make install" // 82 | // End: // 83 | -------------------------------------------------------------------------------- /source/src/library/uPRNG.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 2021 4 | // 5 | // uPRNG.cc -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Sat Dec 25 17:50:36 2021 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sun Dec 11 20:49:44 2022 11 | // Update Count : 83 12 | // 13 | // 14 | // This library is free software; you can redistribute it and/or modify it 15 | // under the terms of the GNU Lesser General Public License as published by the 16 | // Free Software Foundation; either version 2.1 of the License, or (at your 17 | // option) any later version. 18 | // 19 | // This library is distributed in the hope that it will be useful, but WITHOUT 20 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 22 | // for more details. 23 | // 24 | // You should have received a copy of the GNU Lesser General Public License 25 | // along with this library. 26 | // 27 | 28 | 29 | #define __U_KERNEL__ 30 | #include 31 | #include 32 | 33 | //========================================================= 34 | 35 | 36 | // Cannot be inline in uC++.h because of stupid friendship problem with static. 37 | 38 | void set_seed( size_t seed ) { 39 | PRNG_STATE_T & state = uThisTask().random_state; 40 | PRNG_SET_SEED( state, seed ); 41 | uBaseTask::thread_random_seed = seed; 42 | uBaseTask::thread_random_prime = seed; 43 | uBaseTask::thread_random_mask = true; 44 | } // set_seed 45 | 46 | size_t get_seed() { return uBaseTask::thread_random_seed; } 47 | size_t prng() { return PRNG_NAME( uThisTask().random_state ); } 48 | 49 | 50 | // Local Variables: // 51 | // compile-command: "make install" // 52 | // End: // 53 | -------------------------------------------------------------------------------- /source/src/library/uPoll.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr 1994 4 | // 5 | // uPoll.h -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Tue Mar 29 17:01:20 1994 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Tue Apr 19 12:23:42 2022 11 | // Update Count : 35 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | #define U_FNDELAY FNDELAY 32 | #define U_EWOULDBLOCK EWOULDBLOCK 33 | 34 | 35 | class uPoll { 36 | public: 37 | enum PollStatus { NeverPoll, PollOnDemand, AlwaysPoll }; 38 | private: 39 | PollStatus uStatus; 40 | public: 41 | PollStatus getStatus() { 42 | return uStatus; 43 | } // uPoll::getStatus 44 | 45 | void setStatus( PollStatus s ) { 46 | uStatus = s; 47 | } // uPoll::setStatus 48 | 49 | void setPollFlag( int fd ); 50 | void clearPollFlag( int fd ); 51 | void computeStatus( int fd ); 52 | }; // uPoll 53 | 54 | 55 | // Local Variables: // 56 | // compile-command: "make install" // 57 | // End: // 58 | -------------------------------------------------------------------------------- /source/src/profiler/Makefile: -------------------------------------------------------------------------------- 1 | ## Define the appropriate configuration variables. 2 | 3 | PACKAGE = /u0/usystem/software/u++-7.0.0 4 | 5 | ## Include the architecture dependent definitions. 6 | 7 | include ${PACKAGE}/CONFIG 8 | 9 | ## Define the path names of important directories. 10 | 11 | SRCDIR = ${PACKAGE}/src/profiler 12 | 13 | ## Define some of the tools. 14 | 15 | include ${PACKAGE}/src/MakeTools 16 | 17 | ## Define the special object files. 18 | 19 | MODSRC = ${addprefix ${SRCDIR}/, ${addsuffix .cc, \ 20 | uProfilerFunctionPointers \ 21 | } } 22 | 23 | ## Define the header files 24 | 25 | HEADERS = ${shell ls *.h} 26 | 27 | ## Define the things that can be defined based upon previous definitions. 28 | 29 | include ${PACKAGE}/src/MakeDefinitions 30 | 31 | ## Define the specific recipes. 32 | 33 | all : ${MODULES} 34 | 35 | INSTALLFILES = ${addprefix ${INSTALLLIBDIR}/, ${notdir ${MODULES}}} ${addprefix ${INSTALLINCDIR}/, ${HEADERS}} 36 | 37 | install : all ${INSTALLFILES} 38 | 39 | ## Define default dependencies and recipes for object files. 40 | 41 | include ${PACKAGE}/src/MakeRecipes 42 | 43 | ## Include the dependencies for object files and libraries. 44 | 45 | -include ${DEPENDS} 46 | 47 | ## Create directories (TEMPORARY: fixed in gmake 3.80) 48 | 49 | _xxx1 := ${shell mkdir -p ${LIBDIR} ${OBJDIR}} 50 | 51 | ifeq (${MAKECMDGOALS},install) 52 | _xxx2 := ${shell mkdir -p ${INSTALLLIBDIR} ${INSTALLINCDIR}} 53 | endif 54 | 55 | ## Local Variables: ## 56 | ## compile-command: "make install" ## 57 | ## End: ## 58 | -------------------------------------------------------------------------------- /source/src/scheduler/Makefile: -------------------------------------------------------------------------------- 1 | ## Define the appropriate configuration variables. 2 | 3 | PACKAGE = /u0/usystem/software/u++-7.0.0 4 | 5 | ## Include the architecture dependent definitions. 6 | 7 | include ${PACKAGE}/CONFIG 8 | 9 | ## Define the path names of important directories. 10 | 11 | SRCDIR = ${PACKAGE}/src/scheduler 12 | 13 | ## Define some of the tools. 14 | 15 | include ${PACKAGE}/src/MakeTools 16 | 17 | ## Define the C++ source files. 18 | 19 | LIBSRC = ${addprefix ${SRCDIR}/, ${addsuffix .cc, \ 20 | uDeadlineMonotonic \ 21 | uDeadlineMonotonic1 \ 22 | uDeadlineMonotonicStatic \ 23 | uLifoScheduler \ 24 | uRealTime \ 25 | uHeapQ \ 26 | uPIHeap \ 27 | uStaticPriorityQ \ 28 | uStaticPIQ \ 29 | } } 30 | 31 | LIBSRC-D = ${LIBSRC} 32 | ifeq (${MULTI},TRUE) 33 | LIBSRC-M = ${LIBSRC} 34 | LIBSRC-M-D = ${LIBSRC} 35 | endif 36 | 37 | ## Define the header files 38 | 39 | HEADERS = ${shell ls *.h} 40 | 41 | ## Define which libraries should be built. 42 | 43 | LIB = ${LIBDIR}/uScheduler.a 44 | LIB-D = ${LIBDIR}/uScheduler-d.a 45 | ifeq (${MULTI},TRUE) 46 | LIB-M = ${LIBDIR}/uScheduler-m.a 47 | LIB-M-D = ${LIBDIR}/uScheduler-m-d.a 48 | endif 49 | 50 | ## Define the things that can be defined based upon previous definitions. 51 | 52 | include ${PACKAGE}/src/MakeDefinitions 53 | 54 | ## Define the specific recipes. 55 | 56 | all : ${LIBRARIES} 57 | 58 | INSTALLFILES = ${addprefix ${INSTALLLIBDIR}/, ${notdir ${LIBRARIES}}} ${addprefix ${INSTALLINCDIR}/, ${HEADERS}} 59 | 60 | install : all ${INSTALLFILES} 61 | 62 | ## Define default dependencies and recipes for object files. 63 | 64 | include ${PACKAGE}/src/MakeRecipes 65 | 66 | ## Include the dependencies for object files and libraries. 67 | 68 | -include ${DEPENDS} 69 | 70 | ## Create directories (TEMPORARY: fixed in gmake 3.80) 71 | 72 | _xxx1 := ${shell mkdir -p ${LIBDIR} ${OBJDIR}} 73 | 74 | ifeq (${MAKECMDGOALS},install) 75 | _xxx2 := ${shell mkdir -p ${INSTALLLIBDIR} ${INSTALLINCDIR}} 76 | endif 77 | 78 | ## Local Variables: ## 79 | ## compile-command: "make install" ## 80 | ## End: ## 81 | -------------------------------------------------------------------------------- /source/src/scheduler/uDeadlineMonotonic.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Philipp E. Lim 1996 4 | // 5 | // uDeadlineMonotonic.h -- 6 | // 7 | // Author : Philipp E. Lim and Ashif S. Harji 8 | // Created On : Fri Jul 19 23:20:17 1996 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sat Apr 9 16:59:05 2022 11 | // Update Count : 139 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | #include 32 | 33 | 34 | class uDeadlineMonotonic : public uPriorityScheduleSeq { 35 | int compare( uBaseTask &task1, uBaseTask &task2 ); 36 | public: 37 | void addInitialize( uSequence &taskList ); 38 | void removeInitialize( uSequence & ); 39 | void rescheduleTask( uBaseTaskDL *taskNode, uBaseTaskSeq &taskList ); 40 | }; // uDeadlineMonotonic 41 | 42 | 43 | // Local Variables: // 44 | // compile-command: "make install" // 45 | // End: // 46 | -------------------------------------------------------------------------------- /source/src/scheduler/uDeadlineMonotonic1.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Philipp E. Lim 1996 4 | // 5 | // uDeadlineMonotonic.h -- 6 | // 7 | // Author : Philipp E. Lim and Ashif S. Harji 8 | // Created On : Fri Jul 19 23:20:17 1996 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sat Apr 9 17:01:04 2022 11 | // Update Count : 248 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | #include 32 | #include 33 | 34 | 35 | class uDeadlineMonotonic1 : public uPriorityScheduleQSeq { 36 | public: 37 | void addInitialize( uSequence &taskList ); 38 | void removeInitialize( uSequence & ); 39 | void rescheduleTask( uBaseTaskDL *taskNode, uBaseTaskSeq &taskList ); 40 | }; // uDeadlineMonotonic1 41 | 42 | 43 | // Local Variables: // 44 | // compile-command: "make install" // 45 | // End: // 46 | -------------------------------------------------------------------------------- /source/src/scheduler/uDeadlineMonotonicStatic.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Ashif S. Harji 2000 4 | // 5 | // uDeadlineMonotonic.h -- 6 | // 7 | // Author : Ashif S. Harji 8 | // Created On : Fri Oct 27 16:09:42 2000 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sat Apr 9 17:03:06 2022 11 | // Update Count : 158 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | #include 32 | #include 33 | 34 | 35 | class uDeadlineMonotonicStatic : public uStaticPriorityScheduleSeq { 36 | int compare( uBaseTask &task1, uBaseTask &task2 ); 37 | public: 38 | void addInitialize( uSequence &taskList ); 39 | void removeInitialize( uSequence & ); 40 | void rescheduleTask( uBaseTaskDL *taskNode, uBaseTaskSeq &taskList ); 41 | }; // uDeadlineMonotonicStatic 42 | 43 | 44 | // Local Variables: // 45 | // compile-command: "make install" // 46 | // End: // 47 | -------------------------------------------------------------------------------- /source/src/scheduler/uLifoScheduler.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Jiongxiong Chen and Ashif S. Harji 2003 4 | // 5 | // uLifoScheduler.h -- 6 | // 7 | // Author : Jiongxiong Chen and Ashif S. Harji 8 | // Created On : Fri Feb 14 14:26:49 2003 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sat Apr 9 17:05:58 2022 11 | // Update Count : 148 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #define __U_KERNEL__ 28 | #include 29 | #include 30 | 31 | 32 | //#include 33 | 34 | bool uLifoScheduler::empty() const { 35 | return list.empty(); 36 | } // uLifoScheduler::empty 37 | 38 | void uLifoScheduler::add( uBaseTaskDL *node ) { 39 | list.addTail( node ); 40 | } // uLifoScheduler::add 41 | 42 | uBaseTaskDL *uLifoScheduler::drop() { 43 | uBaseTaskDL *temp = list.dropTail(); 44 | return temp; 45 | } // uLifoScheduler::drop 46 | 47 | bool uLifoScheduler::checkPriority( uBaseTaskDL &, uBaseTaskDL & ) { return false; } 48 | 49 | void uLifoScheduler::resetPriority( uBaseTaskDL &, uBaseTaskDL & ) {} 50 | 51 | void uLifoScheduler::addInitialize( uBaseTaskSeq & ) {}; 52 | 53 | void uLifoScheduler::removeInitialize( uBaseTaskSeq & ) {}; 54 | 55 | void uLifoScheduler::rescheduleTask( uBaseTaskDL *, uBaseTaskSeq & ) {}; 56 | 57 | 58 | // Local Variables: // 59 | // compile-command: "make install" // 60 | // End: // 61 | -------------------------------------------------------------------------------- /source/src/scheduler/uLifoScheduler.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Jiongxiong Chen and Ashif S. Harji 2003 4 | // 5 | // uLifoScheduler.h -- 6 | // 7 | // Author : Jiongxiong Chen and Ashif S. Harji 8 | // Created On : Fri Feb 14 14:26:49 2003 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sat Apr 9 17:06:10 2022 11 | // Update Count : 148 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | #include 32 | 33 | class uLifoScheduler : public uBaseSchedule { 34 | uBaseTaskSeq list; // list of tasks awaiting execution 35 | public: 36 | bool empty() const; 37 | void add( uBaseTaskDL *node ); 38 | uBaseTaskDL *drop(); 39 | bool checkPriority( uBaseTaskDL &owner, uBaseTaskDL &calling ); 40 | void resetPriority( uBaseTaskDL &owner, uBaseTaskDL &calling ); 41 | void addInitialize( uBaseTaskSeq &taskList ); 42 | void removeInitialize( uBaseTaskSeq &taskList ); 43 | void rescheduleTask( uBaseTaskDL *taskNode, uBaseTaskSeq &taskList ); 44 | }; // uLifoScheduler 45 | 46 | 47 | // Local Variables: // 48 | // compile-command: "make install" // 49 | // End: // 50 | -------------------------------------------------------------------------------- /source/src/scheduler/uPIHeap.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Ashif S. Harji 2000 4 | // 5 | // uPIHeap.h -- 6 | // 7 | // Author : Ashif S. Harji 8 | // Created On : Fri Jan 14 17:53:22 2000 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sat Apr 9 17:07:15 2022 11 | // Update Count : 27 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | //#include 32 | 33 | #include 34 | 35 | 36 | #define __U_MAX_NUMBER_PRIORITIES__ 32 37 | 38 | 39 | class uPIHeap : public uBasePIQ { 40 | struct uHeapBaseSeq { 41 | int index; 42 | int count; 43 | int queueNum; 44 | //uBaseTaskSeq queue; 45 | }; 46 | 47 | uHeapBaseSeq objects[ __U_MAX_NUMBER_PRIORITIES__ ]; 48 | uHeap heap; 49 | uSpinLock lock; 50 | 51 | static int compare(int k1, int k2); 52 | static void exchange( uHeapable &x, uHeapable &y ); 53 | public: 54 | uPIHeap(); 55 | virtual bool empty() const; 56 | virtual int head() const; 57 | virtual int getHighestPriority(); 58 | virtual void add( int priority, int queueNum ); 59 | virtual int drop(); 60 | virtual void remove( int priority, int queueNum ); 61 | }; // PIHeap 62 | 63 | 64 | // Local Variables: // 65 | // compile-command: "make install" // 66 | // End: // 67 | -------------------------------------------------------------------------------- /source/src/scheduler/uStaticPIQ.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Ashif S. Harji 2000 4 | // 5 | // uStaticPIQ.h -- 6 | // 7 | // Author : Ashif S. Harji 8 | // Created On : Fri Jan 14 17:53:22 2000 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sat Apr 9 17:10:35 2022 11 | // Update Count : 39 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | //#include 32 | 33 | #include 34 | 35 | 36 | // TEMPORARY: where should this be defined?? 37 | #define __U_MAX_NUMBER_PRIORITIES__ 32 38 | 39 | 40 | class uStaticPIQ : public uBasePIQ { 41 | int objects[ __U_MAX_NUMBER_PRIORITIES__ ]; 42 | uSpinLock lock; 43 | unsigned int mask; 44 | 45 | static int compare( int k1, int k2 ); 46 | public: 47 | uStaticPIQ(); 48 | virtual bool empty() const; 49 | //virtual int head(); 50 | virtual int getHighestPriority(); 51 | virtual void add( int priority ); 52 | virtual int drop(); 53 | virtual void remove( int priority ); 54 | }; // PIHeap 55 | 56 | 57 | // Local Variables: // 58 | // compile-command: "make install" // 59 | // End: // 60 | -------------------------------------------------------------------------------- /source/src/translator/attribute.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard A. Stroobosscher 1994 4 | // 5 | // attribute.cc -- 6 | // 7 | // Author : Richard A. Stroobosscher 8 | // Created On : Tue Apr 28 16:02:53 1992 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Fri Dec 24 17:18:08 2021 11 | // Update Count : 59 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include "attribute.h" 28 | 29 | attribute_t::attribute_t() { 30 | Mutex = false; 31 | dclkind.value = dclmutex.value = dclqual.value = 0; 32 | rttskkind.value = 0; 33 | typedef_base = nullptr; 34 | focus = nullptr; 35 | emptyparms = nestedqual = false; 36 | plate = nullptr; 37 | startT = endT = startParms = endParms = startRet = endRet = startCR = startI = startE = startM = endM = startP = endP = nullptr; 38 | } // attribute_t::attribute_t 39 | 40 | attribute_t::~attribute_t() { 41 | Mutex = false; 42 | dclkind.value = dclmutex.value = dclqual.value = 0; 43 | rttskkind.value = 0; 44 | typedef_base = nullptr; 45 | focus = nullptr; 46 | emptyparms = nestedqual = false; 47 | plate = nullptr; 48 | startT = endT = startParms = endParms = startRet = endRet = startCR = startI = startE = startM = endM = startP = endP = nullptr; 49 | } // attribute_t::~attribute_t 50 | 51 | // Local Variables: // 52 | // compile-command: "make install" // 53 | // End: // 54 | -------------------------------------------------------------------------------- /source/src/translator/debug.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard A. Stroobosscher 1994 4 | // 5 | // debug.h -- 6 | // 7 | // Author : Peter A. Buhr 8 | // Created On : Mon Feb 20 06:53:20 2017 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Mon Jan 21 09:19:02 2019 11 | // Update Count : 3 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | #ifdef __U_DEBUG_H__ 32 | #define uDEBUGPRT( stmt ) stmt 33 | #else 34 | #define uDEBUGPRT( stmt ) 35 | #endif // __U_DEBUG_H__ 36 | 37 | 38 | // Local Variables: // 39 | // compile-command: "make install" // 40 | // End: // 41 | -------------------------------------------------------------------------------- /source/src/translator/hash.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard A. Stroobosscher 1994 4 | // 5 | // hash.h -- 6 | // 7 | // Author : Richard A. Stroobosscher 8 | // Created On : Tue Apr 28 15:37:36 1992 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Fri Dec 24 17:25:54 2021 11 | // Update Count : 33 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | // should be a prime number 32 | #define HASH_TABLE_SIZE 1009 33 | 34 | 35 | class hash_t { 36 | friend class hash_table_t; 37 | public: 38 | char * text; 39 | hash_t * link; 40 | int value; 41 | int InSymbolTable; 42 | public: 43 | hash_t( const char *, hash_t *, int value ); 44 | ~hash_t(); 45 | }; 46 | 47 | 48 | class hash_table_t { 49 | private: 50 | hash_t * table[HASH_TABLE_SIZE]; 51 | public: 52 | hash_table_t(); 53 | ~hash_table_t(); 54 | hash_t * lookup( const char *, int value = 0 ); 55 | }; 56 | 57 | extern hash_table_t * hash_table; 58 | 59 | 60 | 61 | // Local Variables: // 62 | // compile-command: "make install" // 63 | // End: // 64 | -------------------------------------------------------------------------------- /source/src/translator/input.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard A. Stroobosscher 1994 4 | // 5 | // input.h -- 6 | // 7 | // Author : Richard A. Stroobosscher 8 | // Created On : Tue Apr 28 15:38:14 1992 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Mon Jan 21 09:09:46 2019 11 | // Update Count : 23 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | void read_all_input(); 32 | 33 | 34 | // Local Variables: // 35 | // compile-command: "make install" // 36 | // End: // 37 | -------------------------------------------------------------------------------- /source/src/translator/main.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard A. Stroobosscher 1994 4 | // 5 | // main.h -- 6 | // 7 | // Author : Richard A. Stroobosscher 8 | // Created On : Tue Apr 28 16:06:46 1992 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Fri Dec 24 18:07:39 2021 11 | // Update Count : 32 12 | // 13 | 14 | 15 | #pragma once 16 | 17 | 18 | #include 19 | 20 | using std::istream; 21 | using std::ostream; 22 | 23 | extern istream * yyin; 24 | extern ostream * yyout; 25 | 26 | extern bool error; 27 | extern bool profile; 28 | extern bool stdcpp11; 29 | extern bool user; 30 | 31 | int main( int argc, char * argv[] ); 32 | 33 | 34 | 35 | // Local Variables: // 36 | // compile-command: "make install" // 37 | // End: // 38 | -------------------------------------------------------------------------------- /source/src/translator/output.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard A. Stroobosscher 1994 4 | // 5 | // output.h -- 6 | // 7 | // Author : Richard A. Stroobosscher 8 | // Created On : Tue Apr 28 15:41:53 1992 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Mon Jan 21 09:10:22 2019 11 | // Update Count : 21 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | #include 32 | 33 | extern token_t * file_token; 34 | extern char file[]; 35 | extern unsigned int line, flag; 36 | extern const char * flags[]; 37 | void parse_directive( char * text, char file[], unsigned int & line, unsigned int & flag ); 38 | 39 | void write_all_output(); 40 | 41 | 42 | 43 | // Local Variables: // 44 | // compile-command: "make install" // 45 | // End: // 46 | -------------------------------------------------------------------------------- /source/src/translator/parse.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard A. Stroobosscher 1994 4 | // 5 | // parse.h -- 6 | // 7 | // Author : Richard A. Stroobosscher 8 | // Created On : Tue Apr 28 15:42:30 1992 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Mon Jan 21 09:18:01 2019 11 | // Update Count : 13 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | void translation_unit(); 32 | 33 | 34 | 35 | // Local Variables: // 36 | // compile-command: "make install" // 37 | // End: // 38 | -------------------------------------------------------------------------------- /source/src/translator/scan.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard A. Stroobosscher 1994 4 | // 5 | // scan.h -- 6 | // 7 | // Author : Richard A. Stroobosscher 8 | // Created On : Tue Apr 28 15:43:34 1992 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Fri Dec 24 18:10:58 2021 11 | // Update Count : 14 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | void scan(); 32 | void unscan( token_t * back ); 33 | 34 | 35 | 36 | // Local Variables: // 37 | // compile-command: "make install" // 38 | // End: // 39 | -------------------------------------------------------------------------------- /source/src/translator/structor.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard A. Stroobosscher 1994 4 | // 5 | // structor.c -- 6 | // 7 | // Author : Richard A. Stroobosscher 8 | // Created On : Tue Apr 28 15:17:01 1992 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Fri Dec 24 18:11:39 2021 11 | // Update Count : 33 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include "structor.h" 28 | 29 | structor_t::structor_t() { 30 | prefix = nullptr; 31 | suffix = nullptr; 32 | rp = nullptr; 33 | link = nullptr; 34 | } // structor_t::structor_t 35 | 36 | 37 | structor_t::~structor_t() { 38 | } // structor_t::structor_t 39 | 40 | 41 | structor_list_t::structor_list_t() : head( nullptr ) { 42 | } // structor_list_t:: structor_list_t 43 | 44 | 45 | structor_list_t::~structor_list_t() { 46 | } // structor_list_t::~structor_list_t 47 | 48 | 49 | void structor_list_t::add_structor( structor_t * structor ) { 50 | structor->link = head; 51 | head = structor; 52 | } // structor_list_t::add_structor 53 | 54 | 55 | structor_t * structor_list_t::remove_structor() { 56 | structor_t * structor = head; 57 | head = structor->link; 58 | return structor; 59 | } // structor_list_t::remove_structor 60 | 61 | 62 | int structor_list_t::empty_structor_list() { 63 | return ( head == nullptr ); 64 | } // structor_list_t::empty_structor_list 65 | 66 | 67 | // Local Variables: // 68 | // compile-command: "make install" // 69 | // End: // 70 | -------------------------------------------------------------------------------- /source/src/translator/structor.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard A. Stroobosscher 1994 4 | // 5 | // structor.h -- 6 | // 7 | // Author : Richard A. Stroobosscher 8 | // Created On : Tue Apr 28 15:46:34 1992 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Fri Dec 24 18:12:22 2021 11 | // Update Count : 34 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | 31 | #include "attribute.h" 32 | 33 | struct token_t; 34 | 35 | class structor_t { 36 | public: 37 | char separator; // separator cahracter before base-class initializer 38 | token_t * start; // first token of non-base class initializer 39 | token_t * prefix; // '{' of constructor/destructor 40 | token_t * suffix; // '}' of constructor/destructor 41 | token_t * rp; // ')' of constructor parameter list 42 | declmutex dclmutex; // mutex qualifier of constructor/destructor 43 | bool defarg; 44 | structor_t * link; // next constructor 45 | structor_t(); 46 | ~structor_t(); 47 | }; 48 | 49 | class structor_list_t { 50 | public: 51 | structor_t * head; 52 | structor_list_t(); 53 | ~structor_list_t(); 54 | void add_structor( structor_t * structor ); 55 | structor_t * remove_structor(); 56 | int empty_structor_list(); 57 | }; 58 | 59 | 60 | 61 | // Local Variables: // 62 | // compile-command: "make install" // 63 | // End: // 64 | -------------------------------------------------------------------------------- /source/src/translator/symbol.cc: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard A. Stroobosscher 1994 4 | // 5 | // symbol.c -- 6 | // 7 | // Author : Richard A. Stroobosscher 8 | // Created On : Tue Apr 28 15:18:22 1992 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Fri Dec 24 18:13:35 2021 11 | // Update Count : 77 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | #include "table.h" 28 | #include "symbol.h" 29 | 30 | #include "hash.h" 31 | #include 32 | using std::cerr; 33 | using std::endl; 34 | 35 | //#define __U_DEBUG_H__ 36 | #include "debug.h" 37 | 38 | symbol_data_t::symbol_data_t() { 39 | found = nullptr; 40 | table = nullptr; 41 | key = 0; 42 | index = DESTRUCTORPOSN; // start allocating entry bits from this value 43 | base = nullptr; 44 | used = false; 45 | base_token = nullptr; 46 | left = right = nullptr; 47 | } // symbol_data_t::symbol_data_t 48 | 49 | 50 | symbol_t::symbol_t( int v, hash_t * h ) { 51 | value = v; 52 | hash = h; 53 | copied = typname = false; 54 | data = new symbol_data_t; 55 | uDEBUGPRT(cerr << "add1 symbol " << hash->text << endl; ); 56 | } // symbol_t::symbol_t 57 | 58 | 59 | symbol_t::symbol_t( const symbol_t &other ) { 60 | value = other.value; 61 | hash = other.hash; 62 | copied = false; 63 | data = new symbol_data_t; 64 | uDEBUGPRT( cerr << "add2 symbol " << hash->text << endl; ); 65 | } // symbol_t::symbol_t 66 | 67 | 68 | symbol_t::~symbol_t() { 69 | uDEBUGPRT( cerr << "delete symbol " << hash->text << endl; ); 70 | if ( ! copied ) { // data shared for typedef and using 71 | delete data->table; 72 | delete data; 73 | data = nullptr; 74 | } // if 75 | copied = false; 76 | } // symbol_t::~symbol_t 77 | 78 | // Local Variables: // 79 | // compile-command: "make install" // 80 | // End: // 81 | -------------------------------------------------------------------------------- /source/src/translator/token.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard A. Stroobosscher 1994 4 | // 5 | // token.h -- 6 | // 7 | // Author : Richard A. Stroobosscher 8 | // Created On : Tue Apr 28 15:48:16 1992 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Sat Aug 20 07:38:45 2022 11 | // Update Count : 65 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | 28 | #pragma once 29 | 30 | #include // size_t 31 | 32 | class hash_t; 33 | struct symbol_t; 34 | 35 | struct token_t { 36 | token_t * fore; // next token 37 | token_t * aft; // previous token 38 | int value; // lexer code for token 39 | hash_t * hash; // hashed token entry 40 | symbol_t * symbol; // symbol table for identifiers 41 | token_t * left; // start of base_specifier 42 | token_t * right; // end of base_specifier 43 | 44 | void init() { symbol = nullptr; left = right = nullptr; } 45 | token_t() { hash = nullptr; init(); } 46 | token_t( int value, hash_t * hash ) : value( value ), hash( hash ) { init(); } 47 | ~token_t(); 48 | void add_token_after( token_t &before ); 49 | void add_token_before( token_t &after ); 50 | void remove_token(); 51 | token_t * next_parse_token(); 52 | token_t * prev_parse_token(); 53 | }; // token_t 54 | 55 | 56 | extern token_t * ahead; // current token being parsed 57 | 58 | 59 | class token_list_t { 60 | private: 61 | token_t head; 62 | token_t tail; 63 | public: 64 | token_list_t(); 65 | ~token_list_t(); 66 | void add_to_head( token_t &insert ); 67 | void add_to_tail( token_t &insert ); 68 | token_t * remove_from_head(); 69 | token_t * remove_from_tail(); 70 | token_t * get_head(); 71 | token_t * get_tail(); 72 | int empty(); 73 | }; // token_list_t 74 | 75 | 76 | extern token_list_t * token_list; 77 | 78 | 79 | // Local Variables: // 80 | // compile-command: "make install" // 81 | // End: // 82 | -------------------------------------------------------------------------------- /source/src/translator/uassert.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: C++ -*- 2 | // 3 | // uC++ Version 7.0.0, Copyright (C) Peter A. Buhr and Richard A. Stroobosscher 1994 4 | // 5 | // assert.h -- 6 | // 7 | // Author : Richard A. Stroobosscher 8 | // Created On : Tue Apr 28 16:01:41 1992 9 | // Last Modified By : Peter A. Buhr 10 | // Last Modified On : Fri Dec 24 18:21:20 2021 11 | // Update Count : 38 12 | // 13 | // This library is free software; you can redistribute it and/or modify it 14 | // under the terms of the GNU Lesser General Public License as published by the 15 | // Free Software Foundation; either version 2.1 of the License, or (at your 16 | // option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, but WITHOUT 19 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 21 | // for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public License 24 | // along with this library. 25 | // 26 | 27 | // This include file is not suppose to be idempotent, so there is no guard. 28 | 29 | 30 | #undef assert 31 | 32 | #ifdef NDEBUG 33 | 34 | #define uassert( expr ) ((void)0) 35 | 36 | #else 37 | 38 | #include 39 | #include // exit 40 | 41 | using std::cerr; 42 | using std::endl; 43 | 44 | #include "output.h" 45 | #include "gen.h" 46 | 47 | #define uassert( expr ) \ 48 | if ( ! ( expr ) ) { \ 49 | cerr << __FILE__ << ":" << __LINE__ << ": assertion failed" << endl; \ 50 | gen_error( ahead, "assertion failed at this line." ); \ 51 | write_all_output(); \ 52 | exit( EXIT_FAILURE ); \ 53 | } // if 54 | 55 | #endif // NDEBUG 56 | 57 | 58 | // Local Variables: // 59 | // compile-command: "make install" // 60 | // End: // 61 | -------------------------------------------------------------------------------- /u++-7.0.0.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pabuhr/uCPP/b637d596f2c24f052826927705e89841143a5c72/u++-7.0.0.sh --------------------------------------------------------------------------------