Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
ok
  • Loading branch information
DavidMorano committed Apr 3, 2024
1 parent 8235417 commit af3585c
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 178 deletions.
180 changes: 61 additions & 119 deletions src/testa/Makefile
Original file line number Diff line number Diff line change
@@ -1,167 +1,109 @@
# MAKEFILE
# MAKEFILE (testa)

T= testa

ALL = $(T) $(T).$(OFF)
ALL= $(T).x

SRCROOT= $(LOCAL)

BINDIR= $(REPOROOT)/bin
INCDIR= $(REPOROOT)/include
LIBDIR= $(REPOROOT)/lib
MANDIR= $(REPOROOT)/man
INFODIR= $(REPOROOT)/info
HELPDIR= $(REPOROOT)/share/help

BINDIR= $(SRCROOT)/bin
INCDIR= $(SRCROOT)/include
LIBDIR= $(SRCROOT)/lib

#LDCRTDIR= /opt/SUNWspro/WS6/lib
#LDCRTDIR= /opt/SUNWspro/SC5.0/lib
#LDCRTDIR= /opt/SUNWspro/SC4.0/lib
#LDCRTDIR= /opt/SUNWspro/lib
LDCRTDIR= $(SRCROOT)/lib
CRTDIR= $(CGS_CRTDIR)
VALDIR= $(CGS_VALDIR)
LIBDIR= $(CGS_LIBDIR)

CPP= cpp
CC= gcc
CXX= gpp
LD= gld
RANLIB= granlib
AR= gar
NM= gnm
COV= gcov

CC= gcc
LORDER= lorder
TSORT= tsort
LINT= lint
RM= rm -f
TOUCH= touch
LINT= lint

CCOPTS= -O3 -mcpu=ultrasparc # -fpic
#CCOPTS= -g
#CCOPTS= -g -pg

# HyperSPARC
#CCOPTS= -xO5 -xtarget=ss20/hs22 -dalign -xdepend

# UltraSPARC
#CCOPTS= -xO5 -xtarget=ultra -xsafe=mem -dalign -xdepend


DEF0=
DEF1=
DEF2=
DEF3=
DEF4=
DEF5=
DEF6=
DEF7= $(LF_DEFS)

DEFS= $(DEF0) $(DEF1) $(DEF2) $(DEF3) $(DEF4) $(DEF5) $(DEF6)


INCDIRS= -I$(INCDIR)

CPPFLAGS= $(DEFS) $(INCDIRS)

CFLAGS= $(CCOPTS)

#LD= $(CC)
#LD= cc
LD= ld

LDFLAGS= -m -R$(LIBDIR)
DEFS=

LDRPATH= $(EXTRA)/lib

LIBDIRS= -L$(LIBDIR)

LIB0=
LIB1= -ldam -lb -luc
LIB2=
LIB3= -Bstatic -lu -Bdynamic
LIB4= -L$(GNU)/lib -lgcc
LIB5=
LIB6= -lsecdb -lproject -lpthread -lrt -lxnet -lsocket -lnsl
LIB7= -ldl -lc

LIBS= $(LIB0) $(LIB1) $(LIB2) $(LIB3) $(LIB4) $(LIB5) $(LIB6) $(LIB7)


CRTI= $(LDCRTDIR)/crti.o
CRT1= $(LDCRTDIR)/crt1.o
VALUES= $(LDCRTDIR)/values-xa.o
CRTN= $(LDCRTDIR)/crtn.o

CRT0= $(CRTI) $(CRT1) $(VALUES)
CRTC= makedate.o
LIBS= -lmacuser

LINT= lint
LINTFLAGS= -uxn -Dlint

NM= nm
NMFLAGS= -xs

CPP= cpp
# flag setting
CPPFLAGS= $(DEFS) $(INCDIRS) $(MAKECPPFLAGS)
CFLAGS= $(MAKECFLAGS)
CCFLAGS= $(MAKECCFLAGS)
ARFLAGS= $(MAKEARFLAGS)
LDFLAGS= $(MAKELDFLAGS)


INCS=


OBJ00=
OBJ01= main.o
OBJ02=
OBJ03=
OBJ04=
OBJ05=
OBJ06=
OBJ07=

OBJA= $(OBJ00) $(OBJ01) $(OBJ02) $(OBJ03) $(OBJ04) $(OBJ05) $(OBJ06) $(OBJ07)
OBJB= $(OBJ08) $(OBJ09) $(OBJ10) $(OBJ11) $(OBJ12) $(OBJ13) $(OBJ14) $(OBJ15)

OBJ= $(OBJA) $(OBJB)

OBJS= $(CRT0) $(OBJ) $(CRTC)


.SUFFIXES: .ls
OBJ_ENDIAN= main.o


default: $(T).x

all: $(ALL)

.c.o:
$(CC) -c $(CFLAGS) $(CPPFLAGS) $<

.c.ln:
$(LINT) -c -u $(CPPFLAGS) $<
$(LINT) -c $(LINTFLAGS) $(CPPFLAGS) $<

.c.ls:
$(LINT) $(LINTFLAGS) $(CPPFLAGS) $<

.c.i:
$(CPP) $(CPPFLAGS) $< > $(*).i

$(T): $(T).ee
cp -p $(T).ee $(T)
.c.o:
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<

$(T).x: $(OBJ) Makefile
makedate -m $(T) > makedate.c
$(CC) -c $(CFLAGS) makedate.c
$(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBDIRS) $(LIBS) $(CRTN) > $(T).lm
.cc.o:
$(CXX) $(CPPFLAGS) $(CCFLAGS) -c $<

$(T).$(OFF) $(OFF): $(T).x
cp -p $(T).x $(T).$(OFF)

strip: $(T).x
strip $(T).x
rm -f $(T).$(OFF) $(T)
$(T).x: $(OBJ_ENDIAN)
$(LD) $(LDFLAGS) -o $@ $(LIBDIRS) $(LIBS) $(OBJ_ENDIAN)

install: $(ALL)
bsdinstall $(ALL) $(BINDIR)
$(T).o: $(OBJ_ENDIAN)
$(LD) $(LDFLAGS) -r -o $@ $(OBJ_ENDIAN)

install-raw: $(T).x
cp -p $(T).x $(T)
rm -f $(BINDIR)/$(T).$(OFF)
bsdinstall $(T) $(BINDIR)
$(T).a: $(OBJ_ENDIAN)
$(AR) $(ARFLAGS) -rc $@ $?

again:
rm -f $(ALL) $(T).x
$(T).nm: $(T).o
$(NM) $(NMFLAGS) $(T).o > $(T).nm

clean: again
rm -f *.o

control:
uname -n > Control
date >> Control
$(T).order: $(OBJ_ENDIAN) $(T).a
$(LORDER) $(T).a | $(TSORT) > $(T).order
$(RM) $(T).a
while read O ; do $(AR) $(ARFLAGS) -cr $(T).a $${O} ; done < $(T).order

again:
rm -f $(ALL)

main.o: main.c config.h
clean:
makeclean $(ALL)

whatinfo.o: whatinfo.c config.h
control:
(uname -n ; date) > Control


main.o: main.cc $(INCS)


120 changes: 61 additions & 59 deletions src/testa/main.cc
Original file line number Diff line number Diff line change
@@ -1,95 +1,97 @@
/* main (TESTA) */
/* lang=C++20 */


#include <envstandards.h>

#include <envstandards.h> /* MUST be ordered first to configure */
#include <sys/types.h>
#include <string.h>
#include <stdio.h>

#include <cstring>
#include <cstdio>
#include <iostream>
#include <usystem.h>
#include <mallocstuff.h>

#include <localmisc.h>

/* local defines */

#define NI 20
#define NJ 2

int main()
{
int a[20][2] ;
int typesize, size ;
int n, i, j ;
int *p ;
char *(*keys)[2] ;
/* forward references */

n = 2 * 20 ;
static int sub(int (*)[NJ],int,int) ;

typesize = sizeof(uint (*)[2]) ;
/* local variables */

printf("1 typesize=%u\n",typesize) ;
constexpr cchar str[] = "hello" ;

typesize = sizeof(char *) ;
/* exported subroutines */

printf("2 typesize=%u\n",typesize) ;

size = n * typesize ;
(void) uc_malloc(size,&keys) ;

memset(keys,0,size) ;

printf("typesize=%u n=%u size=%u\n",typesize,n,size) ;

keys[0][0] = "hello" ;
keys[0][1] = "there" ;
int main() {
int a[NI][NJ] ;
int typesize ;
int sz ;
int n, i, j ;
int *p ;

keys[1][0] = "good" ;
keys[1][1] = "bye" ;
sz = sizeof(str) ;
printf("sizeof=%u\v",sz) ;

for (i = 0 ; i < 2 ; i += 1) {
n = NI * NJ ;
typesize = sizeof(uint (*)[NJ]) ;

if (keys[i][0] != NULL)
printf("k=%s v=%s\n",
keys[i][0],keys[i][1]) ;
printf("1 typesize=%u\n",typesize) ;

}
typesize = sizeof(char *) ;

printf("2 typesize=%u\n",typesize) ;

size = n * sizeof(int) ;
(void) memset(a,0,size) ;
#ifdef COMMENT
{
cchar *(*keys)[NJ] ;
sz = n * typesize ;
(void) uc_malloc(sz,&keys) ;
memset(keys,0,sz) ;
printf("typesize=%u n=%u size=%u\n",typesize,n,sz) ;
keys[0][0] = "hello" ;
keys[0][1] = "there" ;
keys[1][0] = "good" ;
keys[1][1] = "bye" ;
for (i = 0 ; i < NJ ; i += 1) {
if (keys[i][0] != nullptr) {
printf("k=%s v=%s\n", keys[i][0],keys[i][1]) ;
}
} /* end for */
} /* end block */
#endif /* COMMENT */

sz = n * sizeof(int) ;
memset(a,0,sz) ;

p = (int *) a ;
for (i = 0 ; i < n ; i += 1)
for (i = 0 ; i < n ; i += 1) {
p[i] = i ;

for (i = 0 ; i < 20 ; i += 1) {

for (j = 0 ; j < 2 ; j += 1)
printf("[%2d,%2d]=%d\n",
i,j,a[i][j]) ;

}

sub(a,2) ;
for (i = 0 ; i < NI ; i += 1) {
for (j = 0 ; j < NJ ; j += 1) {
printf("[%2d,%2d]=%d\n",i,j,a[i][j]) ;
}
}

fclose(stdout) ;
sub(a,NI,NJ) ;

return 0 ;
}
/* end subroutine (main) */


int sub(a,rn)
int rn ;
int (*a)[2] ;
{
int i, j ;

for (i = 0 ; i < 20 ; i += 1) {
for (j = 0 ; j < 2 ; j += 1) {
printf("sub [%2d,%2d]=%d\n",
i,j,a[i][j]) ;
static int sub(int (*a)[2],int ni,int nj) {
for (int i = 0 ; i < ni ; i += 1) {
for (int j = 0 ; j < nj ; j += 1) {
printf("sub [%2d,%2d]=%d\n",i,j,a[i][j]) ;
}
}

return 0 ;
}
/* end subroutine (sub) */


0 comments on commit af3585c

Please sign in to comment.