Commit c3e5f1c6 authored by Alessandro Rubini's avatar Alessandro Rubini

general (and big): rename arch-gnu-linux to arch-unix

The contents of this directory are pretty portable anyways, and
the internal files were actually called "posix-io.c" and so on.
So let's get rid of the too-politica "gnu-linux" naming and of
the too-little-political "posix" at the same time.  We build
on Unix roots, so let's call our architecture like that.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
Acked-by: Aurelio Colosimo's avatarAurelio Colosimo <aurelio@aureliocolosimo.it>
parent 2e9affcf
......@@ -42,17 +42,17 @@ make -s -C tools clean; make -s -C tools
make -s -C tools/mtp clean; make -s -C tools/mtp
# Variables to set up proper stuff for the various architectures
PREFIX_gnu_linux=""
PREFIX_unix=""
PREFIX_bare_i386=""
PREFIX_bare_x86_64=""
PREFIX_wrpc="/opt/gcc-lm32/bin/lm32-elf-"
CC_gnu_linux="gcc"
CC_unix="gcc"
CC_bare_i386="gcc -m32"
CC_bare_x86_64="gcc -m64"
CC_wrpc="${PREFIX_wrpc}gcc"
LD_gnu_linux="ld"
LD_unix="ld"
LD_bare_i386="ld -m elf_i386"
LD_bare_x86_64="ld -m elf_x86_64"
LD_wrpc="${PREFIX_wrpc}ld"
......@@ -60,7 +60,7 @@ LD_wrpc="${PREFIX_wrpc}ld"
# Defaults, overridden by command line, later
SHOW_UNDEF=false
ARCHS="gnu-linux bare-i386 bare-x86-64"
ARCHS="unix bare-i386 bare-x86-64"
if [ "x${WRPCSW_ROOT}" != "x" ]; then
ARCHS="$ARCHS wrpc"
fi
......@@ -68,7 +68,9 @@ fi
# Parse command line, so we can limit the archs we build for
while [ $# -gt 0 ]; do
case $1 in
gnu-linux)
gnu-linux) # The previous name we used
ARCHS="unix";;
unix)
ARCHS="$1";;
bare-i386)
ARCHS="$1";;
......
......@@ -6,7 +6,7 @@
# PROTO_EXT ?= whiterabbit
# The default architecture is hosted GNU/Linux stuff
ARCH ?= gnu-linux
ARCH ?= unix
# Also, you can set USER_CFLAGS, like this (or on the command line)
# USER_CFLAGS = -DVERB_LOG_MSGS -DCONFIG_PPSI_RUNTIME_VERBOSITY
......
/*
* Alessandro Rubini for CERN, 2011 -- public domain
*/
/*
* These are the functions provided by the various posix files
*/
#define POSIX_ARCH(ppg) ((struct posix_arch_data *)(ppg->arch_data))
struct posix_arch_data {
struct timeval tv;
};
extern int posix_net_check_pkt(struct pp_globals *ppg, int delay_ms);
extern void posix_main_loop(struct pp_globals *ppg);
extern struct pp_network_operations posix_net_ops;
extern struct pp_time_operations posix_time_ops;
......@@ -8,11 +8,11 @@ CFLAGS += -DCONFIG_PPSI_RUNTIME_VERBOSITY -Itools
LIBARCH := $A/libarch.a
OBJ-libarch := $A/posix-startup.o \
OBJ-libarch := $A/unix-startup.o \
$A/main-loop.o \
$A/posix-socket.o \
$A/posix-io.o \
$A/posix-time.o \
$A/unix-socket.o \
$A/unix-io.o \
$A/unix-time.o \
lib/cmdline.o \
lib/conf.o \
lib/libc-functions.o \
......
......@@ -3,7 +3,7 @@
*/
/*
* This is the main loop for posix stuff.
* This is the main loop for unix stuff.
*/
#include <stdlib.h>
#include <errno.h>
......@@ -11,7 +11,7 @@
#include <linux/if_ether.h>
#include <ppsi/ppsi.h>
#include "posix.h"
#include "ppsi-unix.h"
/* Call pp_state_machine for each instance. To be called periodically,
* when no packets are incoming */
......@@ -34,7 +34,7 @@ static int run_all_state_machines(struct pp_globals *ppg)
return delay_ms;
}
void posix_main_loop(struct pp_globals *ppg)
void unix_main_loop(struct pp_globals *ppg)
{
struct pp_instance *ppi;
int delay_ms;
......@@ -81,7 +81,7 @@ void posix_main_loop(struct pp_globals *ppg)
ppg->ebest_updated = 0;
}
i = posix_net_check_pkt(ppg, delay_ms);
i = unix_net_check_pkt(ppg, delay_ms);
if (i < 0)
continue;
......@@ -91,7 +91,7 @@ void posix_main_loop(struct pp_globals *ppg)
continue;
}
/* If delay_ms is -1, the above posix_net_check_pkt will continue
/* If delay_ms is -1, the above unix_net_check_pkt will continue
* consuming the previous timeout (see its implementation).
* This ensures that every state machine is called at least once
* every delay_ms */
......
/*
* Alessandro Rubini for CERN, 2011 -- public domain
*/
/*
* These are the functions provided by the various unix files
*/
#define POSIX_ARCH(ppg) ((struct unix_arch_data *)(ppg->arch_data))
struct unix_arch_data {
struct timeval tv;
};
extern int unix_net_check_pkt(struct pp_globals *ppg, int delay_ms);
extern void unix_main_loop(struct pp_globals *ppg);
extern struct pp_network_operations unix_net_ops;
extern struct pp_time_operations unix_time_ops;
......@@ -18,10 +18,10 @@
#include <ppsi/ppsi.h>
#include "ptpdump.h"
#include "posix.h"
#include "ppsi-unix.h"
/* posix_recv_msg uses recvmsg for timestamp query */
static int posix_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
/* unix_recv_msg uses recvmsg for timestamp query */
static int unix_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
TimeInternal *t)
{
ssize_t ret;
......@@ -90,7 +90,7 @@ static int posix_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
}
/* Receive and send is *not* so trivial */
static int posix_net_recv(struct pp_instance *ppi, void *pkt, int len,
static int unix_net_recv(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t)
{
struct pp_channel *ch1, *ch2;
......@@ -99,7 +99,7 @@ static int posix_net_recv(struct pp_instance *ppi, void *pkt, int len,
if (ppi->ethernet_mode) {
int fd = NP(ppi)->ch[PP_NP_GEN].fd;
ret = posix_recv_msg(ppi, fd, pkt, len, t);
ret = unix_recv_msg(ppi, fd, pkt, len, t);
if (ret > 0 && pp_diag_allow(ppi, frames, 2))
dump_1588pkt("recv: ", pkt, ret, t);
return ret;
......@@ -112,16 +112,16 @@ static int posix_net_recv(struct pp_instance *ppi, void *pkt, int len,
ret = -1;
if (ch1->pkt_present)
ret = posix_recv_msg(ppi, ch1->fd, pkt, len, t);
ret = unix_recv_msg(ppi, ch1->fd, pkt, len, t);
else if (ch2->pkt_present)
ret = posix_recv_msg(ppi, ch2->fd, pkt, len, t);
ret = unix_recv_msg(ppi, ch2->fd, pkt, len, t);
if (ret > 0 && pp_diag_allow(ppi, frames, 2))
dump_payloadpkt("recv: ", pkt, ret, t);
return ret;
}
static int posix_net_send(struct pp_instance *ppi, void *pkt, int len,
static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr)
{
struct sockaddr_in addr;
......@@ -161,7 +161,7 @@ static int posix_net_send(struct pp_instance *ppi, void *pkt, int len,
}
/* To open a channel we must bind to an interface and so on */
static int posix_open_ch(struct pp_instance *ppi, char *ifname, int chtype)
static int unix_open_ch(struct pp_instance *ppi, char *ifname, int chtype)
{
int sock = -1;
......@@ -324,34 +324,34 @@ err_out:
return -1;
}
static int posix_net_exit(struct pp_instance *ppi);
static int unix_net_exit(struct pp_instance *ppi);
/*
* Inits all the network stuff
*/
/* This function must be able to be called twice, and clean-up internally */
int posix_net_init(struct pp_instance *ppi)
int unix_net_init(struct pp_instance *ppi)
{
int i;
if (NP(ppi)->ch[0].fd)
posix_net_exit(ppi);
unix_net_exit(ppi);
/* The buffer is inside ppi, but we need to set pointers and align */
pp_prepare_pointers(ppi);
if (ppi->ethernet_mode) {
pp_diag(ppi, frames, 1, "posix_net_init IEEE 802.3\n");
pp_diag(ppi, frames, 1, "unix_net_init IEEE 802.3\n");
/* raw sockets implementation always use gen socket */
return posix_open_ch(ppi, ppi->iface_name, PP_NP_GEN);
return unix_open_ch(ppi, ppi->iface_name, PP_NP_GEN);
}
/* else: UDP */
pp_diag(ppi, frames, 1, "posix_net_init UDP\n");
pp_diag(ppi, frames, 1, "unix_net_init UDP\n");
for (i = PP_NP_GEN; i <= PP_NP_EVT; i++) {
if (posix_open_ch(ppi, ppi->iface_name, i))
if (unix_open_ch(ppi, ppi->iface_name, i))
return -1;
}
return 0;
......@@ -360,7 +360,7 @@ int posix_net_init(struct pp_instance *ppi)
/*
* Shutdown all the network stuff
*/
static int posix_net_exit(struct pp_instance *ppi)
static int unix_net_exit(struct pp_instance *ppi)
{
struct ip_mreq imr;
int fd;
......@@ -394,13 +394,13 @@ static int posix_net_exit(struct pp_instance *ppi)
return 0;
}
int posix_net_check_pkt(struct pp_globals *ppg, int delay_ms)
int unix_net_check_pkt(struct pp_globals *ppg, int delay_ms)
{
fd_set set;
int i, j;
int ret = 0;
int maxfd = 0;
struct posix_arch_data *arch_data = POSIX_ARCH(ppg);
struct unix_arch_data *arch_data = POSIX_ARCH(ppg);
if (delay_ms != -1) {
/* Wait for a packet or for the timeout */
......@@ -466,9 +466,9 @@ int posix_net_check_pkt(struct pp_globals *ppg, int delay_ms)
return ret;
}
struct pp_network_operations posix_net_ops = {
.init = posix_net_init,
.exit = posix_net_exit,
.recv = posix_net_recv,
.send = posix_net_send,
struct pp_network_operations unix_net_ops = {
.init = unix_net_init,
.exit = unix_net_exit,
.recv = unix_net_recv,
.send = unix_net_send,
};
......@@ -17,7 +17,7 @@
#include <ppsi/ppsi.h>
#include "posix.h"
#include "ppsi-unix.h"
CONST_VERBOSITY int pp_diag_verbosity = 0;
......@@ -80,7 +80,7 @@ int main(int argc, char **argv)
ppg->currentDS = calloc(1, sizeof(*ppg->currentDS));
ppg->parentDS = calloc(1, sizeof(*ppg->parentDS));
ppg->timePropertiesDS = calloc(1, sizeof(*ppg->timePropertiesDS));
ppg->arch_data = calloc(1, sizeof(struct posix_arch_data));
ppg->arch_data = calloc(1, sizeof(struct unix_arch_data));
ppg->pp_instances = calloc(ppg->nlinks, sizeof(struct pp_instance));
if ((!ppg->defaultDS) || (!ppg->currentDS) || (!ppg->parentDS)
......@@ -110,8 +110,8 @@ int main(int argc, char **argv)
/* FIXME set ppi ext enable as defined in its pp_link */
ppi->portDS = calloc(1, sizeof(*ppi->portDS));
ppi->n_ops = &posix_net_ops;
ppi->t_ops = &posix_time_ops;
ppi->n_ops = &unix_net_ops;
ppi->t_ops = &unix_time_ops;
if (!ppi->portDS)
exit(__LINE__);
......@@ -122,6 +122,6 @@ int main(int argc, char **argv)
pp_open_globals(ppg);
posix_main_loop(ppg);
unix_main_loop(ppg);
return 0; /* never reached */
}
......@@ -16,7 +16,7 @@ static void clock_fatal_error(char *context)
exit(1);
}
static int posix_time_get(struct pp_instance *ppi, TimeInternal *t)
static int unix_time_get(struct pp_instance *ppi, TimeInternal *t)
{
struct timespec tp;
if (clock_gettime(CLOCK_REALTIME, &tp) < 0)
......@@ -29,7 +29,7 @@ static int posix_time_get(struct pp_instance *ppi, TimeInternal *t)
return 0;
}
int32_t posix_time_set(struct pp_instance *ppi, TimeInternal *t)
int32_t unix_time_set(struct pp_instance *ppi, TimeInternal *t)
{
struct timespec tp;
......@@ -42,7 +42,7 @@ int32_t posix_time_set(struct pp_instance *ppi, TimeInternal *t)
return 0;
}
int posix_time_adjust(struct pp_instance *ppi, long offset_ns, long freq_ppm)
int unix_time_adjust(struct pp_instance *ppi, long offset_ns, long freq_ppm)
{
struct timex t;
int ret;
......@@ -69,17 +69,17 @@ int posix_time_adjust(struct pp_instance *ppi, long offset_ns, long freq_ppm)
return ret;
}
int posix_time_adjust_offset(struct pp_instance *ppi, long offset_ns)
int unix_time_adjust_offset(struct pp_instance *ppi, long offset_ns)
{
return posix_time_adjust(ppi, offset_ns, 0);
return unix_time_adjust(ppi, offset_ns, 0);
}
int posix_time_adjust_freq(struct pp_instance *ppi, long freq_ppm)
int unix_time_adjust_freq(struct pp_instance *ppi, long freq_ppm)
{
return posix_time_adjust(ppi, 0, freq_ppm);
return unix_time_adjust(ppi, 0, freq_ppm);
}
static unsigned long posix_calc_timeout(struct pp_instance *ppi, int millisec)
static unsigned long unix_calc_timeout(struct pp_instance *ppi, int millisec)
{
struct timespec now;
uint64_t now_ms;
......@@ -94,11 +94,11 @@ static unsigned long posix_calc_timeout(struct pp_instance *ppi, int millisec)
return result ? result : 1; /* cannot return 0 */
}
struct pp_time_operations posix_time_ops = {
.get = posix_time_get,
.set = posix_time_set,
.adjust = posix_time_adjust,
.adjust_offset = posix_time_adjust_offset,
.adjust_freq = posix_time_adjust_freq,
.calc_timeout = posix_calc_timeout,
struct pp_time_operations unix_time_ops = {
.get = unix_time_get,
.set = unix_time_set,
.adjust = unix_time_adjust,
.adjust_offset = unix_time_adjust_offset,
.adjust_freq = unix_time_adjust_freq,
.calc_timeout = unix_calc_timeout,
};
......@@ -132,10 +132,10 @@ The package currently supports the following architectures:
@table @i
@item gnu-linux
@item unix
This is the default architecture and is the normal @i{hosted}
environment. The architecture supports the Linux
environment. The architecture is usually tested over the Linux
kernel using the standard GNU libraries. Most of the code relies
on standard @sc{posix} conventions, so this architecture most
likely works on @sc{bsd} and other variants as well. We may
......@@ -640,15 +640,15 @@ for further details.
This is an example run, limited to hosted compilation:
@example
% ./MAKEALL gnu-linux
###### Build for arch "gnu-linux", ext "", printf xint
% ./MAKEALL unix
###### Build for arch "unix", ext "", printf xint
text data bss dec hex filename
17681 224 264 18169 46f9 ppsi.o
29079 936 512 30527 773f ppsi
###### Build for arch "gnu-linux", ext "", all messages
15801 224 344 16369 3ff1 ppsi.o
34370 984 380 35734 8b96 ppsi
###### Build for arch "unix", ext "", all messages
text data bss dec hex filename
18695 224 264 19183 4aef ppsi.o
30095 936 512 31543 7b37 ppsi
16850 224 344 17418 440a ppsi.o
35410 984 380 36774 8fa6 ppsi
@end example
@c ##########################################################################
......@@ -685,7 +685,7 @@ in order to add their own stuff (like the @i{main} function or @i{crt0.o}
for freestanding stuff). Similarly, architectures can add files
to the "all" target. The main Makefile only builds @i{ppsi.o},
leaving the final link to the chosen architecture, so for example
@i{arch-gnu-linux} adds @t{ppsi} to the @t{all} target.
@i{arch-unix} adds @t{ppsi} to the @t{all} target.
Since code and data space is a problem in the freestanding world (for
example, the whole ptp may need to fit in 64kB RAM including data and
......
......@@ -40,7 +40,7 @@ struct pp_runtime_opts {
extern struct pp_runtime_opts default_rt_opts; /* preinited with defaults */
/*
* Communication channel. Is the abstraction of a posix socket, so that
* Communication channel. Is the abstraction of a unix socket, so that
* this struct is platform independent
*/
struct pp_channel {
......
......@@ -44,7 +44,7 @@ static int bare_time_adjust(struct pp_instance *ppi, long offset_ns,
/* FIXME: handle MOD_FREQUENCY and MOD_OFFSET separately, and
* set t.modes only for the mode having non-zero parameter.
* See posix_time_adjust in arch-gnu-linux/posix-time.c */
* See unix_time_adjust in arch-unix/unix-time.c */
if (freq_ppm > PP_ADJ_FREQ_MAX)
freq_ppm = PP_ADJ_FREQ_MAX;
if (freq_ppm < -PP_ADJ_FREQ_MAX)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment