SourceForge logo
SourceForge logo
Menu

cadcdev-svn-commits — Source Code Repository Updates

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
(35)
Dec
(2)
2004 Jan
(37)
Feb
(10)
Mar
Apr
(2)
May
(17)
Jun
(1)
Jul
(14)
Aug
(14)
Sep
(4)
Oct
Nov
(14)
Dec
(4)
2005 Jan
(6)
Feb
Mar
Apr
(6)
May
Jun
Jul
Aug
Sep
(1)
Oct
Nov
(92)
Dec
(12)
2006 Jan
(3)
Feb
(4)
Mar
Apr
(5)
May
(3)
Jun
(15)
Jul
(3)
Aug
(1)
Sep
(29)
Oct
(1)
Nov
(6)
Dec
(5)
2007 Jan
(2)
Feb
(2)
Mar
Apr
(3)
May
(14)
Jun
(2)
Jul
(16)
Aug
(73)
Sep
(12)
Oct
(9)
Nov
(27)
Dec
(3)
2008 Jan
(4)
Feb
(4)
Mar
(3)
Apr
(8)
May
(23)
Jun
(4)
Jul
(1)
Aug
(3)
Sep
(7)
Oct
(5)
Nov
(1)
Dec
(1)
2009 Jan
Feb
(10)
Mar
Apr
(4)
May
(4)
Jun
(10)
Jul
Aug
(1)
Sep
Oct
(7)
Nov
Dec
(1)
2010 Jan
Feb
(1)
Mar
Apr
(6)
May
Jun
(3)
Jul
(11)
Aug
(1)
Sep
Oct
(15)
Nov
(1)
Dec
(5)
2011 Jan
(4)
Feb
(1)
Mar
(6)
Apr
May
(22)
Jun
Jul
(8)
Aug
(2)
Sep
Oct
Nov
Dec
(2)
2012 Jan
Feb
(10)
Mar
(1)
Apr
(6)
May
(27)
Jun
(48)
Jul
(30)
Aug
(4)
Sep
Oct
(3)
Nov
(1)
Dec
(11)
2013 Jan
(4)
Feb
(7)
Mar
(6)
Apr
(18)
May
(28)
Jun
(20)
Jul
Aug
(4)
Sep
(1)
Oct
(1)
Nov
(2)
Dec
(7)
2014 Jan
(3)
Feb
(2)
Mar
(4)
Apr
(9)
May
(11)
Jun
(10)
Jul
Aug
(18)
Sep
(12)
Oct
(17)
Nov
(10)
Dec
(16)
2015 Jan
(5)
Feb
(1)
Mar
(5)
Apr
(4)
May
(28)
Jun
(2)
Jul
Aug
Sep
(6)
Oct
Nov
(2)
Dec
(1)
2016 Jan
(14)
Feb
Mar
(3)
Apr
May
Jun
(3)
Jul
(4)
Aug
(4)
Sep
(1)
Oct
(1)
Nov
Dec
(1)
2017 Jan
(11)
Feb
Mar
(21)
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
(1)
Apr
May
(1)
Jun
Jul
Aug
(2)
Sep
(4)
Oct
(4)
Nov
Dec
(1)
2019 Jan
(1)
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
(13)
Sep
(4)
Oct
Nov
Dec
2020 Jan
(10)
Feb
(9)
Mar
(5)
Apr
(4)
May
(3)
Jun
(18)
Jul
(4)
Aug
(2)
Sep
(20)
Oct
(2)
Nov
Dec
2021 Jan
Feb
Mar
Apr
(2)
May
(1)
Jun
(2)
Jul
(1)
Aug
(2)
Sep
Oct
Nov
Dec
(2)
2022 Jan
(1)
Feb
(2)
Mar
(2)
Apr
(1)
May
Jun
Jul
Aug
(5)
Sep
Oct
(1)
Nov
Dec
(1)
2023 Jan
(10)
Feb
(7)
Mar
(29)
Apr
(31)
May
(29)
Jun
(34)
Jul
(3)
Aug
(24)
Sep
(22)
Oct
(10)
Nov
(38)
Dec
(27)
2024 Jan
(15)
Feb
(8)
Mar
(4)
Apr
(20)
May
(33)
Jun
(18)
Jul
(15)
Aug
(23)
Sep
(26)
Oct
(32)
Nov
(6)
Dec
(4)
2025 Jan
(7)
Feb
(1)
Mar
(1)
Apr
(4)
May
(46)
Jun
(19)
Jul
(26)
Aug
(48)
Sep
(30)
Oct
(6)
Nov
Dec
S M T W T F S


1
2
(1)
3
4
5
6
7
8
9
10
11
(1)
12
(2)
13
14
15
16
17
18
19
20
(2)
21
22
23
24
25
26
27
28
29
30
31


Showing 6 results of 6

From: <ljs...@us...> - 2011年03月20日 20:26:26
Revision: 709
 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=709&view=rev
Author: ljsebald
Date: 2011年03月20日 20:26:20 +0000 (2011年3月20日)
Log Message:
-----------
Copy IPv6 addresses passed into inet_ntop into an internal buffer to deal with any sort of alignment issues...
Modified Paths:
--------------
 kos/kernel/libc/koslib/inet_ntop.c
 kos/kernel/net/net_icmp6.c
Modified: kos/kernel/libc/koslib/inet_ntop.c
===================================================================
--- kos/kernel/libc/koslib/inet_ntop.c	2011年03月20日 20:22:01 UTC (rev 708)
+++ kos/kernel/libc/koslib/inet_ntop.c	2011年03月20日 20:26:20 UTC (rev 709)
@@ -1,12 +1,13 @@
 /* KallistiOS ##version##
 
 inet_ntop.c
- Copyright (C) 2007, 2010 Lawrence Sebald
+ Copyright (C) 2007, 2010, 2011 Lawrence Sebald
 
 */
 
 #include <arpa/inet.h>
 #include <errno.h>
+#include <string.h>
 
 static const char *inet_ntop4(const void *src, char *dst, socklen_t size) {
 char tmp[3];
@@ -54,21 +55,24 @@
 }
 
 static const char *inet_ntop6(const void *src, char *dst, socklen_t size) {
- struct in6_addr *addr = (struct in6_addr *)src;
 int tmp[8] = { 0 };
 int runstart = -1, maxzero = 0, dcs = -1, i;
 char tmpstr[4];
 char *ch = tmpstr, *ch2 = dst;
 int part;
+ struct in6_addr addr;
 
+ /* Copy the address, just in case the original was misaligned */
+ memcpy(&addr, src, sizeof(struct in6_addr));
+
 /* Handle the special cases of IPv4 Mapped and Compatibility addresses */
- if(IN6_IS_ADDR_V4MAPPED(addr)) {
+ if(IN6_IS_ADDR_V4MAPPED(&addr)) {
 if(size > 7) {
 dst[0] = dst[1] = dst[6] = ':';
 dst[2] = dst[3] = dst[4] = dst[5] = 'f';
 
 /* Parse the IPv4 address at the end */
- if(!inet_ntop4(&addr->__s6_addr.__s6_addr32[3], dst + 7, size - 7))
+ if(!inet_ntop4(&addr.__s6_addr.__s6_addr32[3], dst + 7, size - 7))
 goto err;
 
 return dst;
@@ -77,12 +81,12 @@
 goto err;
 }
 }
- else if(IN6_IS_ADDR_V4COMPAT(addr)) {
+ else if(IN6_IS_ADDR_V4COMPAT(&addr)) {
 if(size > 2) {
 dst[0] = dst[1] = ':';
 
 /* Parse the IPv4 address at the end */
- if(!inet_ntop4(&addr->__s6_addr.__s6_addr32[3], dst + 2, size - 2))
+ if(!inet_ntop4(&addr.__s6_addr.__s6_addr32[3], dst + 2, size - 2))
 goto err;
 
 return dst;
@@ -94,7 +98,7 @@
 
 /* Figure out if we have any use for double colons in the address or not */
 for(i = 0; i < 8; ++i) {
- if(addr->__s6_addr.__s6_addr16[i] == 0) {
+ if(addr.__s6_addr.__s6_addr16[i] == 0) {
 if(runstart != -1) {
 ++tmp[runstart];
 }
@@ -141,7 +145,7 @@
 }
 }
 else {
- part = ntohs(addr->__s6_addr.__s6_addr16[i]);
+ part = ntohs(addr.__s6_addr.__s6_addr16[i]);
 
 do {
 *ch = (char)(part & 0x0f) + '0';
Modified: kos/kernel/net/net_icmp6.c
===================================================================
--- kos/kernel/net/net_icmp6.c	2011年03月20日 20:22:01 UTC (rev 708)
+++ kos/kernel/net/net_icmp6.c	2011年03月20日 20:26:20 UTC (rev 709)
@@ -40,11 +40,8 @@
 uint64 delta_us, uint8 hlim,
 const uint8 *data, int data_sz) {
 char ipstr[INET6_ADDRSTRLEN];
- struct in6_addr a;
 
- /* Copy the address to prevent unaligned accesses... */
- memcpy(&a, ip, sizeof(struct in6_addr));
- inet_ntop(AF_INET6, &a, ipstr, INET6_ADDRSTRLEN);
+ inet_ntop(AF_INET6, ip, ipstr, INET6_ADDRSTRLEN);
 
 if(delta_us != (uint64)-1) {
 printf("%d bytes from %s, icmp_seq=%d hlim=%d time=%.3f ms\n", data_sz,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ljs...@us...> - 2011年03月20日 20:22:08
Revision: 708
 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=708&view=rev
Author: ljsebald
Date: 2011年03月20日 20:22:01 +0000 (2011年3月20日)
Log Message:
-----------
Add in pthread-mapped TLS functionality.
Modified Paths:
--------------
 kos/include/kos/once.h
 kos/include/sys/sched.h
 kos/kernel/libc/pthreads/pthread_tls.c
 kos/kernel/thread/once.c
 kos/kernel/thread/thread.c
Modified: kos/include/kos/once.h
===================================================================
--- kos/include/kos/once.h	2011年03月12日 22:14:07 UTC (rev 707)
+++ kos/include/kos/once.h	2011年03月20日 20:22:01 UTC (rev 708)
@@ -29,10 +29,13 @@
 This object type should always be initialized with the KTHREAD_ONCE_INIT
 macro.
 */
-typedef int kthread_once_t;
+typedef struct {
+ int initialized;
+ int run;
+} kthread_once_t;
 
 /** \brief Initializer for a kthread_once_t object. */
-#define KTHREAD_ONCE_INIT 0
+#define KTHREAD_ONCE_INIT { 1, 0 }
 
 /** \brief Run a function once.
 
Modified: kos/include/sys/sched.h
===================================================================
--- kos/include/sys/sched.h	2011年03月12日 22:14:07 UTC (rev 707)
+++ kos/include/sys/sched.h	2011年03月20日 20:22:01 UTC (rev 708)
@@ -23,6 +23,8 @@
 #include <kos/sem.h>
 #include <kos/cond.h>
 #include <kos/mutex.h>
+#include <kos/tls.h>
+#include <kos/once.h>
 
 // Missing structs we don't care about in this impl.
 typedef struct {
@@ -37,21 +39,15 @@
 	// Empty
 } pthread_attr_t;
 
-typedef struct {
-	int initialized;
-	int run;
-} pthread_once_t;
-
-typedef struct {
-	// Empty
-} pthread_key_t;
-
 // Map over KOS types. The mutex/condvar maps have to be pointers
 // because we allow _INIT #defines to work.
 typedef kthread_t * pthread_t;
 typedef mutex_t * pthread_mutex_t;
 typedef condvar_t * pthread_cond_t;
 
+// These, on the other hand, map right over.
+typedef kthread_once_t pthread_once_t;
+typedef kthread_key_t pthread_key_t;
 
 __END_DECLS
 
Modified: kos/kernel/libc/pthreads/pthread_tls.c
===================================================================
--- kos/kernel/libc/pthreads/pthread_tls.c	2011年03月12日 22:14:07 UTC (rev 707)
+++ kos/kernel/libc/pthreads/pthread_tls.c	2011年03月20日 20:22:01 UTC (rev 708)
@@ -3,27 +3,27 @@
 
 /* Dynamic Package Initialization */
 int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) {
-	return EINVAL;
+	return kthread_once(once_control, init_routine);
 }
 
 /* Thread-Specific Data Key Create, P1003.1c/Draft 10, p. 163 */
 
 int pthread_key_create(pthread_key_t *key, void (*destructor)( void * )) {
-	return EINVAL;
+	return kthread_key_create(key, destructor);
 }
 
 /* Thread-Specific Data Management, P1003.1c/Draft 10, p. 165 */ 
 
 int pthread_setspecific(pthread_key_t key, const void *value) {
-	return EINVAL;
+	return kthread_setspecific(key, value);
 }
 
 void * pthread_getspecific(pthread_key_t key) {
-	return NULL;
+	return kthread_getspecific(key);
 }
 
 /* Thread-Specific Data Key Deletion, P1003.1c/Draft 10, p. 167 */
 
 int pthread_key_delete(pthread_key_t key) {
-	return EINVAL;
+	return kthread_key_delete(key);
 }
Modified: kos/kernel/thread/once.c
===================================================================
--- kos/kernel/thread/once.c	2011年03月12日 22:14:07 UTC (rev 707)
+++ kos/kernel/thread/once.c	2011年03月20日 20:22:01 UTC (rev 708)
@@ -24,10 +24,10 @@
 /* Create the lock if needed. */
 old = irq_disable();
 
- if(!lock) {
+ if(!lock) {
 lock = rlock_create();
 
- if(!lock) {
+ if(!lock) {
 return -1;
 }
 }
@@ -35,19 +35,19 @@
 irq_restore(old);
 
 /* Lock the lock. */
- if(rlock_lock(lock) == -1) {
+ if(rlock_lock(lock) == -1) {
 return -1;
 }
 
 /* If the function has already been run, unlock the lock and return. */
- if(*once_control) {
+ if(once_control->run) {
 rlock_unlock(lock);
 return 0;
 }
 
 /* Run the function, set the control, and unlock the lock. */
 init_routine();
- *once_control = 1;
+ once_control->run = 1;
 rlock_unlock(lock);
 
 return 0;
Modified: kos/kernel/thread/thread.c
===================================================================
--- kos/kernel/thread/thread.c	2011年03月12日 22:14:07 UTC (rev 707)
+++ kos/kernel/thread/thread.c	2011年03月20日 20:22:01 UTC (rev 708)
@@ -668,7 +668,7 @@
 old = irq_disable();
 
 /* Search the thread list and make sure that this thread hasn't
- already died and been deallocated. */
+ already died and been deallocated. */
 LIST_FOREACH(t, &thd_list, t_list) {
 if (t == thd)
 break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ljs...@us...> - 2011年03月12日 22:14:13
Revision: 707
 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=707&view=rev
Author: ljsebald
Date: 2011年03月12日 22:14:07 +0000 (2011年3月12日)
Log Message:
-----------
Do the same for IPv4 pings.
Modified Paths:
--------------
 kos/kernel/net/net_icmp.c
 kos/kernel/net/net_icmp6.c
Modified: kos/kernel/net/net_icmp.c
===================================================================
--- kos/kernel/net/net_icmp.c	2011年03月12日 21:42:28 UTC (rev 706)
+++ kos/kernel/net/net_icmp.c	2011年03月12日 22:14:07 UTC (rev 707)
@@ -3,7 +3,7 @@
 kernel/net/net_icmp.c
 
 Copyright (C) 2002 Dan Potter
- Copyright (C) 2005, 2006, 2007, 2009, 2010 Lawrence Sebald
+ Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011 Lawrence Sebald
 
 */
 
@@ -51,24 +51,17 @@
 Any other numbers not listed in the earlier list...
 */
 
-struct ping_pkt {
- LIST_ENTRY(ping_pkt) pkt_list;
- uint8 ip[4];
- uint8 *data;
- int data_sz;
- uint16 icmp_seq;
- uint64 usec;
-};
-
-LIST_HEAD(ping_pkt_list, ping_pkt);
-
-static struct ping_pkt_list pings = LIST_HEAD_INITIALIZER(0);
-
 static void icmp_default_echo_cb(const uint8 *ip, uint16 seq, uint64 delta_us,
 uint8 ttl, const uint8* data, int data_sz) {
- printf("%d bytes from %d.%d.%d.%d: icmp_seq=%d ttl=%d time=%.3f ms\n",
- data_sz, ip[0], ip[1], ip[2], ip[3], seq, ttl,
- delta_us / 1000.0);
+ if(delta_us != (uint64)-1) {
+ printf("%d bytes from %d.%d.%d.%d: icmp_seq=%d ttl=%d time=%.3f ms\n",
+ data_sz, ip[0], ip[1], ip[2], ip[3], seq, ttl,
+ delta_us / 1000.0);
+ }
+ else {
+ printf("%d bytes from %d.%d.%d.%d: icmp_seq=%d ttl=%d\n", data_sz,
+ ip[0], ip[1], ip[2], ip[3], seq, ttl);
+ }
 }
 
 /* The default echo (ping) callback */
@@ -77,25 +70,22 @@
 /* Handle Echo Reply (ICMP type 0) packets */
 static void net_icmp_input_0(netif_t *src, ip_hdr_t *ip, icmp_hdr_t *icmp,
 const uint8 *d, int s) {
- uint64 tmr;
- struct ping_pkt *ping;
+ uint64 tmr, otmr;
 uint16 seq;
 
 tmr = timer_us_gettime64();
 seq = (d[7] | (d[6] << 8));
 
- LIST_FOREACH(ping, &pings, pkt_list) {
- if(ping->icmp_seq == seq) {
- net_icmp_echo_cb((uint8 *)&ip->src, seq, 
- tmr - ping->usec, ip->ttl, d, s);
-
- LIST_REMOVE(ping, pkt_list);
- free(ping->data);
- free(ping);
-
- return;
- }
+ /* Read back the time if we have it */
+ if(s >= sizeof(icmp_hdr_t) + 8) {
+ otmr = ((uint64)d[8] << 56) | ((uint64)d[9] << 48) |
+ ((uint64)d[10] << 40) | ((uint64)d[11] << 32) |
+ (d[12] << 24) | (d[13] << 16) | (d[14] << 8) | (d[15]);
+ net_icmp_echo_cb((uint8 *)&ip->src, seq, tmr - otmr, ip->ttl, d, s);
 }
+ else {
+ net_icmp_echo_cb((uint8 *)&ip->src, seq, -1, ip->ttl, d, s);
+ }
 }
 
 /* Handle Echo (ICMP type 8) packets */
@@ -161,10 +151,11 @@
 int net_icmp_send_echo(netif_t *net, const uint8 ipaddr[4], uint16 ident,
 uint16 seq, const uint8 *data, int size) {
 icmp_hdr_t *icmp;
- struct ping_pkt *newping;
 int r = -1;
- uint8 databuf[sizeof(icmp_hdr_t) + size];
+ uint16 sz = sizeof(icmp_hdr_t) + size + 8;
+ uint8 databuf[sz];
 uint32 src;
+ uint64 t;
 
 icmp = (icmp_hdr_t *)databuf;
 
@@ -174,10 +165,22 @@
 icmp->checksum = 0;
 icmp->misc.m16[0] = htons(ident);
 icmp->misc.m16[1] = htons(seq);
- memcpy(databuf + sizeof(icmp_hdr_t), data, size);
+ memcpy(databuf + sizeof(icmp_hdr_t) + 8, data, size);
 
+ /* Put the time in now, at the latest possible time (since we have to
+ calculate the checksum over it) */
+ t = timer_us_gettime64();
+ databuf[sizeof(icmp_hdr_t) + 0] = t >> 56;
+ databuf[sizeof(icmp_hdr_t) + 1] = t >> 48;
+ databuf[sizeof(icmp_hdr_t) + 2] = t >> 40;
+ databuf[sizeof(icmp_hdr_t) + 3] = t >> 32;
+ databuf[sizeof(icmp_hdr_t) + 4] = t >> 24;
+ databuf[sizeof(icmp_hdr_t) + 5] = t >> 16;
+ databuf[sizeof(icmp_hdr_t) + 6] = t >> 8;
+ databuf[sizeof(icmp_hdr_t) + 7] = t >> 0;
+
 /* Compute the ICMP Checksum */
- icmp->checksum = net_ipv4_checksum(databuf, sizeof(icmp_hdr_t) + size, 0);
+ icmp->checksum = net_ipv4_checksum(databuf, sz, 0);
 
 /* If we're sending to the loopback, set that as our source too. */
 if(ipaddr[0] == 127) {
@@ -187,18 +190,9 @@
 src = net_ipv4_address(net->ip_addr);
 }
 
- newping = (struct ping_pkt*) malloc(sizeof(struct ping_pkt));
- newping->data = (uint8 *)malloc(size);
- newping->data_sz = size;
- newping->icmp_seq = seq;
- memcpy(newping->data, data, size);
- memcpy(newping->ip, ipaddr, 4);
- LIST_INSERT_HEAD(&pings, newping, pkt_list);
+ r = net_ipv4_send(net, databuf, sz, seq, 255, 1, htonl(src),
+ htonl(net_ipv4_address(ipaddr)));
 
- newping->usec = timer_us_gettime64();
- r = net_ipv4_send(net, databuf, sizeof(icmp_hdr_t) + size, seq, 255, 1,
- htonl(src), htonl(net_ipv4_address(ipaddr)));
-
 return r;
 }
 
Modified: kos/kernel/net/net_icmp6.c
===================================================================
--- kos/kernel/net/net_icmp6.c	2011年03月12日 21:42:28 UTC (rev 706)
+++ kos/kernel/net/net_icmp6.c	2011年03月12日 22:14:07 UTC (rev 707)
@@ -1,7 +1,7 @@
 /* KallistiOS ##version##
 
 kernel/net/net_icmp6.c
- Copyright (C) 2010 Lawrence Sebald
+ Copyright (C) 2010, 2011 Lawrence Sebald
 
 */
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ljs...@us...> - 2011年03月12日 21:42:34
Revision: 706
 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=706&view=rev
Author: ljsebald
Date: 2011年03月12日 21:42:28 +0000 (2011年3月12日)
Log Message:
-----------
No real need to keep state about pings...
Modified Paths:
--------------
 kos/kernel/net/net_icmp6.c
Modified: kos/kernel/net/net_icmp6.c
===================================================================
--- kos/kernel/net/net_icmp6.c	2011年03月11日 22:56:59 UTC (rev 705)
+++ kos/kernel/net/net_icmp6.c	2011年03月12日 21:42:28 UTC (rev 706)
@@ -36,27 +36,24 @@
 Any other numbers not listed in the first list...
 */
 
-struct ping_pkt {
- LIST_ENTRY(ping_pkt) pkt_list;
- struct in6_addr ip;
- uint8 *data;
- int data_sz;
- uint16 icmp_seq;
- uint64 usec;
-};
-
-LIST_HEAD(ping_pkt_list, ping_pkt);
-
-static struct ping_pkt_list pings = LIST_HEAD_INITIALIZER(0);
-
 static void icmp6_default_echo_cb(const struct in6_addr *ip, uint16 seq,
 uint64 delta_us, uint8 hlim,
 const uint8 *data, int data_sz) {
 char ipstr[INET6_ADDRSTRLEN];
+ struct in6_addr a;
 
- printf("%d bytes from %s, icmp_seq=%d hlim=%d time=%.3f ms\n", data_sz,
- inet_ntop(AF_INET6, ip, ipstr, INET6_ADDRSTRLEN), seq, hlim,
- delta_us / 1000.0);
+ /* Copy the address to prevent unaligned accesses... */
+ memcpy(&a, ip, sizeof(struct in6_addr));
+ inet_ntop(AF_INET6, &a, ipstr, INET6_ADDRSTRLEN);
+
+ if(delta_us != (uint64)-1) {
+ printf("%d bytes from %s, icmp_seq=%d hlim=%d time=%.3f ms\n", data_sz,
+ ipstr, seq, hlim, delta_us / 1000.0);
+ }
+ else {
+ printf("%d bytes from %s, icmp_seq=%d hlim=%d\n", data_sz, ipstr, seq,
+ hlim);
+ }
 }
 
 /* The default echo (ping6) callback */
@@ -65,27 +62,22 @@
 /* Handle Echo Reply (ICMPv6 type 129) packets */
 static void net_icmp6_input_129(netif_t *net, ipv6_hdr_t *ip, icmp6_hdr_t *icmp,
 const uint8 *d, int s) {
- uint64 tmr;
- struct ping_pkt *ping;
+ uint64 tmr, otmr = 0;
 uint16 seq;
 
 tmr = timer_us_gettime64();
 seq = (d[7] | (d[6] << 8));
 
- LIST_FOREACH(ping, &pings, pkt_list) {
- if(ping->icmp_seq == seq) {
- if(net_icmp6_echo_cb) {
- net_icmp6_echo_cb(&ping->ip, seq, tmr - ping->usec,
- ip->hop_limit, d, s);
- }
-
- LIST_REMOVE(ping, pkt_list);
- free(ping->data);
- free(ping);
-
- return;
- }
+ /* Read back the time if we have it */
+ if(s >= sizeof(icmp6_echo_hdr_t) + 8) {
+ otmr = ((uint64)d[8] << 56) | ((uint64)d[9] << 48) |
+ ((uint64)d[10] << 40) | ((uint64)d[11] << 32) |
+ (d[12] << 24) | (d[13] << 16) | (d[14] << 8) | (d[15]);
+ net_icmp6_echo_cb(&ip->src_addr, seq, tmr - otmr, ip->hop_limit, d, s);
 }
+ else {
+ net_icmp6_echo_cb(&ip->src_addr, seq, -1, ip->hop_limit, d, s);
+ }
 }
 
 /* Handle Echo (ICMPv6 type 128) packets */
@@ -464,10 +456,11 @@
 int net_icmp6_send_echo(netif_t *net, const struct in6_addr *dst, uint16 ident,
 uint16 seq, const uint8 *data, int size) {
 icmp6_echo_hdr_t *echo;
- struct ping_pkt *newping;
- uint8 databuf[sizeof(icmp6_hdr_t) + size + 4];
+ uint8 databuf[sizeof(icmp6_echo_hdr_t) + size + 8];
 struct in6_addr src;
 uint16 cs;
+ uint64 t;
+ uint16 sz = sizeof(icmp6_echo_hdr_t) + size + 8;
 
 if(!net) {
 if(!(net = net_default_dev)) {
@@ -497,25 +490,25 @@
 echo->checksum = 0;
 echo->ident = htons(ident);
 echo->seq = htons(seq);
- memcpy(databuf + sizeof(icmp6_echo_hdr_t), data, size);
+ memcpy(databuf + sizeof(icmp6_echo_hdr_t) + 8, data, size);
 
+ /* Put the time in now, at the latest possible time (since we have to
+ calculate the checksum over it) */
+ t = timer_us_gettime64();
+ databuf[sizeof(icmp6_echo_hdr_t) + 0] = t >> 56;
+ databuf[sizeof(icmp6_echo_hdr_t) + 1] = t >> 48;
+ databuf[sizeof(icmp6_echo_hdr_t) + 2] = t >> 40;
+ databuf[sizeof(icmp6_echo_hdr_t) + 3] = t >> 32;
+ databuf[sizeof(icmp6_echo_hdr_t) + 4] = t >> 24;
+ databuf[sizeof(icmp6_echo_hdr_t) + 5] = t >> 16;
+ databuf[sizeof(icmp6_echo_hdr_t) + 6] = t >> 8;
+ databuf[sizeof(icmp6_echo_hdr_t) + 7] = t >> 0;
+
 /* Compute the ICMP Checksum */
- cs = net_ipv6_checksum_pseudo(&src, dst, sizeof(icmp6_echo_hdr_t) + size,
- IPV6_HDR_ICMP);
- echo->checksum = net_ipv4_checksum(databuf, sizeof(icmp6_echo_hdr_t) + size,
- cs);
+ cs = net_ipv6_checksum_pseudo(&src, dst, sz, IPV6_HDR_ICMP);
+ echo->checksum = net_ipv4_checksum(databuf, sz, cs);
 
- newping = (struct ping_pkt *) malloc(sizeof(struct ping_pkt));
- newping->data = (uint8 *)malloc(size);
- newping->data_sz = size;
- newping->icmp_seq = seq;
- memcpy(newping->data, data, size);
- newping->ip = *dst;
- LIST_INSERT_HEAD(&pings, newping, pkt_list);
-
- newping->usec = timer_us_gettime64();
- return net_ipv6_send(net, databuf, sizeof(icmp6_echo_hdr_t) + size, 0,
- IPV6_HDR_ICMP, &src, dst);
+ return net_ipv6_send(net, databuf, sz, 0, IPV6_HDR_ICMP, &src, dst);
 }
 
 /* Send a Neighbor Solicitation packet on the specified device */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ljs...@us...> - 2011年03月11日 22:57:06
Revision: 705
 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=705&view=rev
Author: ljsebald
Date: 2011年03月11日 22:56:59 +0000 (2011年3月11日)
Log Message:
-----------
Colorized biosfont code, based on that by Chilly Willy. Its not exactly the same as his version, but it is a bit more general this way.
Modified Paths:
--------------
 kos/kernel/arch/dreamcast/hardware/biosfont.c
 kos/kernel/arch/dreamcast/include/dc/biosfont.h
Modified: kos/kernel/arch/dreamcast/hardware/biosfont.c
===================================================================
--- kos/kernel/arch/dreamcast/hardware/biosfont.c	2011年03月02日 21:43:06 UTC (rev 704)
+++ kos/kernel/arch/dreamcast/hardware/biosfont.c	2011年03月11日 22:56:59 UTC (rev 705)
@@ -21,11 +21,20 @@
 
 All the Japanese code is by Kazuaki Matsumoto.
 
+Foreground/background color switching based on code by Chilly Willy.
+
 */
 
 /* Our current conversion mode */
-int bfont_code_mode = BFONT_CODE_ISO8859_1;
+static int bfont_code_mode = BFONT_CODE_ISO8859_1;
 
+/* Current colors/pixel format. Default to white foreground, black background
+ and 16-bit drawing, so the default behavior doesn't change from what it has
+ been forever. */
+static uint32 bfont_fgcolor = 0xFFFFFFFF;
+static uint32 bfont_bgcolor = 0x00000000;
+static int bfont_32bit = 0;
+
 /* Select an encoding for Japanese (or disable) */
 void bfont_set_encoding(int enc) {
 	if (enc < BFONT_CODE_ISO8859_1 || enc > BFONT_CODE_SJIS) {
@@ -34,6 +43,27 @@
 	bfont_code_mode = enc;
 }
 
+/* Set the foreground color and return the old color */
+uint32 bfont_set_foreground_color(uint32 c) {
+	uint32 rv = bfont_fgcolor;
+	bfont_fgcolor = c;
+	return rv;
+}
+
+/* Set the background color and return the old color */
+uint32 bfont_set_background_color(uint32 c) {
+	uint32 rv = bfont_bgcolor;
+	bfont_bgcolor = c;
+	return rv;
+}
+
+/* Set the font to draw in 32 or 16 bit mode */
+int bfont_set_32bit_mode(int on) {
+	int rv = bfont_32bit;
+	bfont_32bit = !!on;
+	return rv;
+}
+
 /* A little assembly that grabs the font address */
 extern uint8* get_font_address();
 asm(
@@ -132,7 +162,7 @@
 }
 
 /* Draw half-width kana */
-void bfont_draw_thin(uint16 *buffer, int bufwidth, int opaque, int c, int iskana) {
+void bfont_draw_thin(void *b, int bufwidth, int opaque, int c, int iskana) {
 	uint8	*ch;
 	uint16	word;
 	int	x, y;
@@ -142,77 +172,152 @@
 	else
 		ch = bfont_find_char(c);
 
-	for (y=0; y<24; ) {
-		/* Do the first row */
-		word = (((uint16)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f);
-		for (x=0; x<12; x++) {
-			if (word & (0x0800 >> x))
-				*buffer = 0xffff;
-			else {
-				if (opaque)
-					*buffer = 0x0000;
+	if (!bfont_32bit) {
+		uint16 *buffer = (uint16 *)b;
+
+		for (y=0; y<24; ) {
+			/* Do the first row */
+			word = (((uint16)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f);
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*buffer = bfont_fgcolor;
+				else {
+					if (opaque)
+						*buffer = bfont_bgcolor;
+				}
+				buffer++;
 			}
-			buffer++;
+			buffer += bufwidth - 12;
+			y++;
+
+			/* Do the second row */
+			word = ( (((uint16)ch[1]) << 8) & 0xf00 ) | ch[2];
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*buffer = bfont_fgcolor;
+				else {
+					if (opaque)
+						*buffer = bfont_bgcolor;
+				}
+				buffer++;
+			}
+			buffer += bufwidth - 12;
+			y++;
+
+			ch += 3;
 		}
-		buffer += bufwidth - 12;
-		y++;
+	}
+	else {
+		uint32 *buffer = (uint32 *)b;
 
-		/* Do the second row */
-		word = ( (((uint16)ch[1]) << 8) & 0xf00 ) | ch[2];
-		for (x=0; x<12; x++) {
-			if (word & (0x0800 >> x))
-				*buffer = 0xffff;
-			else {
-				if (opaque)
-					*buffer = 0x0000;
+		for (y=0; y<24; ) {
+			/* Do the first row */
+			word = (((uint16)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f);
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*buffer = bfont_fgcolor;
+				else {
+					if (opaque)
+						*buffer = bfont_bgcolor;
+				}
+				buffer++;
 			}
-			buffer++;
+			buffer += bufwidth - 12;
+			y++;
+
+			/* Do the second row */
+			word = ( (((uint16)ch[1]) << 8) & 0xf00 ) | ch[2];
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*buffer = bfont_fgcolor;
+				else {
+					if (opaque)
+						*buffer = bfont_bgcolor;
+				}
+				buffer++;
+			}
+			buffer += bufwidth - 12;
+			y++;
+
+			ch += 3;
 		}
-		buffer += bufwidth - 12;
-		y++;
-
-		ch += 3;
 	}
 }
 
 /* Compat function */
-void bfont_draw(uint16 *buffer, int bufwidth, int opaque, int c) {
+void bfont_draw(void *buffer, int bufwidth, int opaque, int c) {
 	bfont_draw_thin(buffer, bufwidth, opaque, c, 0);
 }
 
 /* Draw wide character */
-void bfont_draw_wide(uint16 *buffer, int bufwidth, int opaque, int c) {
+void bfont_draw_wide(void *b, int bufwidth, int opaque, int c) {
 	uint8	*ch = bfont_find_char_jp(c);
 	uint16	word;
 	int	x, y;
 
-	for (y=0; y<24; ) {
-		/* Do the first row */
-		word = (((uint16)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f);
-		for (x=0; x<12; x++) {
-			if (word & (0x0800 >> x))
-				*buffer = 0xffff;
-			else {
-				if (opaque)
-					*buffer = 0x0000;
+	if (!bfont_32bit) {
+		uint16 *buffer = (uint16 *)b;
+
+		for (y=0; y<24; ) {
+			/* Do the first row */
+			word = (((uint16)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f);
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*buffer = bfont_fgcolor;
+				else {
+					if (opaque)
+						*buffer = bfont_bgcolor;
+				}
+				buffer++;
 			}
-			buffer++;
+
+			word = ( (((uint16)ch[1]) << 8) & 0xf00 ) | ch[2];
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*buffer = bfont_fgcolor;
+				else {
+					if (opaque)
+					*buffer = bfont_bgcolor;
+				}
+				buffer++;
+			}
+			buffer += bufwidth - 24;
+			y++;
+
+			ch += 3;
 		}
+	}
+	else {
+		uint32 *buffer = (uint32 *)b;
 
-		word = ( (((uint16)ch[1]) << 8) & 0xf00 ) | ch[2];
-		for (x=0; x<12; x++) {
-			if (word & (0x0800 >> x))
-				*buffer = 0xffff;
-			else {
-				if (opaque)
-				*buffer = 0x0000;
+		for (y=0; y<24; ) {
+			/* Do the first row */
+			word = (((uint16)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f);
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*buffer = bfont_fgcolor;
+				else {
+					if (opaque)
+						*buffer = bfont_bgcolor;
+				}
+				buffer++;
 			}
-			buffer++;
+			
+			word = ( (((uint16)ch[1]) << 8) & 0xf00 ) | ch[2];
+			for (x=0; x<12; x++) {
+				if (word & (0x0800 >> x))
+					*buffer = bfont_fgcolor;
+				else {
+					if (opaque)
+						*buffer = bfont_bgcolor;
+				}
+				buffer++;
+			}
+			buffer += bufwidth - 24;
+			y++;
+			
+			ch += 3;
 		}
-		buffer += bufwidth - 24;
-		y++;
-
-		ch += 3;
 	}
 }
 
@@ -220,8 +325,10 @@
 /* Draw string of full-width (wide) and half-width (thin) characters
 Note that this handles the case of mixed encodings unless Japanese
 support is disabled (BFONT_CODE_ISO8859_1). */
-void bfont_draw_str(uint16 *buffer, int width, int opaque, char *str) {
+void bfont_draw_str(void *b, int width, int opaque, char *str) {
 	uint16 nChr, nMask, nFlag;
+	int adv = bfont_32bit ? 48 : 24; /* Amount to advance, in bytes */
+	uint8 *buffer = (uint8 *)b;
 
 	while (*str) {
 		nFlag = 0;
@@ -250,14 +357,14 @@
 				str++;
 				nChr = (nChr << 8) | (*str & 0xff);
 				bfont_draw_wide(buffer, width, opaque, nChr);
-				buffer += 24;
+				buffer += adv + adv;
 			} else {
 				bfont_draw_thin(buffer, width, opaque, nChr, 1);
-				buffer += 12;
+				buffer += adv;
 			}
 		} else {
 			bfont_draw_thin(buffer, width, opaque, nChr, 0);
-			buffer += 12;
+			buffer += adv;
 		}
 		str++;
 	}
Modified: kos/kernel/arch/dreamcast/include/dc/biosfont.h
===================================================================
--- kos/kernel/arch/dreamcast/include/dc/biosfont.h	2011年03月02日 21:43:06 UTC (rev 704)
+++ kos/kernel/arch/dreamcast/include/dc/biosfont.h	2011年03月11日 22:56:59 UTC (rev 705)
@@ -14,7 +14,7 @@
 Japanese characters.
 
 \author Dan Potter
- \author Kazuaki Matsumoto 
+ \author Kazuaki Matsumoto
 */
 
 #ifndef __DC_BIOSFONT_H
@@ -25,6 +25,38 @@
 
 #include <arch/types.h>
 
+/** \brief Set the font foreground color.
+
+ This function selects the foreground color to draw when a pixel is opaque in
+ the font. The value passed in for the color should be in whatever pixel
+ format that you intend to use for the image produced.
+
+ \param c The color to use.
+ \return The old foreground color.
+*/
+uint32 bfont_set_foreground_color(uint32 c);
+
+/** \brief Set the font background color.
+
+ This function selects the background color to draw when a pixel is drawn in
+ the font. This color is only used for pixels not covered by the font when
+ you have selected to have the font be opaque.
+
+ \param c The color to use.
+ \return The old background color.
+*/
+uint32 bfont_set_background_color(uint32 c);
+
+/** \brief Set the font to draw 32-bit color.
+
+ This function changes whether the font draws colors as 32-bit or 16-bit. The
+ default is to use 16-bit.
+
+ \param on Set to 0 to use 16-bit color, 32-bit otherwise.
+ \return The old state (1 = 32-bit, 0 = 16-bit).
+*/
+int bfont_set_32bit_mode(int on);
+
 /* Constants for the function below */
 #define BFONT_CODE_ISO8859_1 0	/**< \brief ISO-8859-1 (western) charset */
 #define BFONT_CODE_EUC 1 /**< \brief EUC-JP charset */
@@ -85,40 +117,40 @@
 buffer. Calling this is equivalent to calling bfont_draw_thin() with 0 for
 the final parameter.
 
- \param buffer The buffer to draw to (at least 12 x 24 uint16s)
+ \param buffer The buffer to draw to (at least 12 x 24 pixels)
 \param bufwidth The width of the buffer in pixels
 \param opaque If non-zero, overwrite blank areas with black,
 otherwise do not change them from what they are
 \param c The character to draw
 */
-void bfont_draw(uint16 *buffer, int bufwidth, int opaque, int c);
+void bfont_draw(void *buffer, int bufwidth, int opaque, int c);
 
 /** \brief Draw a single thin character to a buffer.
 
 This function draws a single character in the set encoding to the given
 buffer. This only works with ISO-8859-1 characters and half-width kana.
 
- \param buffer The buffer to draw to (at least 12 x 24 uint16s)
+ \param buffer The buffer to draw to (at least 12 x 24 pixels)
 \param bufwidth The width of the buffer in pixels
 \param opaque If non-zero, overwrite blank areas with black,
 otherwise do not change them from what they are
 \param c The character to draw
 \param iskana Set to 1 if the character is a kana, 0 if ISO-8859-1
 */
-void bfont_draw_thin(uint16 *buffer, int bufwidth, int opaque, int c, int iskana);
+void bfont_draw_thin(void *buffer, int bufwidth, int opaque, int c, int iskana);
 
 /** \brief Draw a single wide character to a buffer.
 
 This function draws a single character in the set encoding to the given
 buffer. This only works with full-width kana and kanji.
 
- \param buffer The buffer to draw to (at least 24 x 24 uint16s)
+ \param buffer The buffer to draw to (at least 24 x 24 pixels)
 \param bufwidth The width of the buffer in pixels
 \param opaque If non-zero, overwrite blank areas with black,
 otherwise do not change them from what they are
 \param c The character to draw
 */
-void bfont_draw_wide(uint16 *buffer, int bufwidth, int opaque, int c);
+void bfont_draw_wide(void *buffer, int bufwidth, int opaque, int c);
 
 /** \brief Draw a full string to a buffer.
 
@@ -132,7 +164,7 @@
 otherwise do not change them from what they are
 \param str The string to draw
 */
-void bfont_draw_str(uint16 *buffer, int width, int opaque, char *str);
+void bfont_draw_str(void *buffer, int width, int opaque, char *str);
 
 __END_DECLS
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ljs...@us...> - 2011年03月02日 21:43:12
Revision: 704
 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=704&view=rev
Author: ljsebald
Date: 2011年03月02日 21:43:06 +0000 (2011年3月02日)
Log Message:
-----------
This aught to fix ARGB1555 support in kmgenc.
Modified Paths:
--------------
 kos/utils/kmgenc/kmgenc.c
 kos/utils/kmgenc/kmgenc.h
 kos/utils/kmgenc/readpng.c
Modified: kos/utils/kmgenc/kmgenc.c
===================================================================
--- kos/utils/kmgenc/kmgenc.c	2011年02月02日 08:17:42 UTC (rev 703)
+++ kos/utils/kmgenc/kmgenc.c	2011年03月02日 21:43:06 UTC (rev 704)
@@ -90,8 +90,7 @@
 			out[i] = le16(PACK4444(fc.a, fc.r, fc.g, fc.b));
 			break;
 		case 2:
-			// out[i] = le16(PACK1555(fc.a, fc.r, fc.g, fc.b));
-			exit(-1);
+			out[i] = le16(PACK1555(fc.a, fc.r, fc.g, fc.b));
 			break;
 		}
 	}
Modified: kos/utils/kmgenc/kmgenc.h
===================================================================
--- kos/utils/kmgenc/kmgenc.h	2011年02月02日 08:17:42 UTC (rev 703)
+++ kos/utils/kmgenc/kmgenc.h	2011年03月02日 21:43:06 UTC (rev 704)
@@ -30,7 +30,7 @@
 	( (((int)((b)*15))) << 0) )
 
 #define PACK1555(a, r, g, b) ( \
-	( ((a) ? 0x8000 : 0x0000) | \
+	( (a) ? 0x8000 : 0x0000) | \
 	( (((int)((r)*31))) << 10) | \
 	( (((int)((g)*31))) << 5) | \
 	( (((int)((b)*31))) << 0) )
Modified: kos/utils/kmgenc/readpng.c
===================================================================
--- kos/utils/kmgenc/readpng.c	2011年02月02日 08:17:42 UTC (rev 703)
+++ kos/utils/kmgenc/readpng.c	2011年03月02日 21:43:06 UTC (rev 704)
@@ -11,6 +11,7 @@
 #include <stdlib.h>
 
 #include <png.h> /* libpng header; includes zlib.h */
+#include <zlib.h>
 #include "readpng.h" /* typedefs, common macros, public prototypes */
 
 static png_structp png_ptr = NULL;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 6 results of 6

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /