Skip to content

Commit 886a1cd

Browse files
committed
Merged revisions 85586-85587,85596-85598 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85586 | gregory.p.smith | 2010-10-16 17:17:24 -0700 (Sat, 16 Oct 2010) | 2 lines fix for netbsd. ........ r85587 | gregory.p.smith | 2010-10-16 17:43:10 -0700 (Sat, 16 Oct 2010) | 3 lines applying netbsd-wizs-mod.patch from issue5510 - fixes for netbsd (and dragonflybsd?) ........ r85596 | gregory.p.smith | 2010-10-16 19:14:36 -0700 (Sat, 16 Oct 2010) | 6 lines Fix multiprocessing Semaphore's on netbsd5. SEM_VALUE_MAX is defined as (~0U) on NetBSD which was causing it to appear as -1 when used as a signed int for _multprocessing.SemLock.SEM_VALUE_MAX. This works around the problem by substituting INT_MAX on systems where it appears negative when used as an int. ........ r85597 | gregory.p.smith | 2010-10-16 19:57:19 -0700 (Sat, 16 Oct 2010) | 2 lines skip test_itimer_virtual on NetBSD to prevent the test suite from hanging. ........ r85598 | gregory.p.smith | 2010-10-16 20:09:12 -0700 (Sat, 16 Oct 2010) | 2 lines Avoid hanging the test on netbsd5. ........
1 parent 6913cb0 commit 886a1cd

5 files changed

Lines changed: 46 additions & 9 deletions

File tree

Lib/test/test_signal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,8 @@ def test_itimer_real(self):
438438
self.assertEqual(self.hndl_called, True)
439439

440440
# Issue 3864. Unknown if this affects earlier versions of freebsd also.
441-
@unittest.skipIf(sys.platform=='freebsd6',
442-
'itimer not reliable (does not mix well with threading) on freebsd6')
441+
@unittest.skipIf(sys.platform in ('freebsd6', 'netbsd5'),
442+
'itimer not reliable (does not mix well with threading) on some BSDs.')
443443
def test_itimer_virtual(self):
444444
self.itimer = signal.ITIMER_VIRTUAL
445445
signal.signal(signal.SIGVTALRM, self.sig_vtalrm)

Lib/test/test_socket.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,10 @@ def testGetServBy(self):
351351
# Find one service that exists, then check all the related interfaces.
352352
# I've ordered this by protocols that have both a tcp and udp
353353
# protocol, at least for modern Linuxes.
354-
if sys.platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6',
355-
'freebsd7', 'freebsd8', 'darwin'):
354+
if (sys.platform.startswith('linux') or
355+
sys.platform.startswith('freebsd') or
356+
sys.platform.startswith('netbsd') or
357+
sys.platform == 'darwin'):
356358
# avoid the 'echo' service on this platform, as there is an
357359
# assumption breaking non-standard port/protocol entry
358360
services = ('daytime', 'qotd', 'domain')

Lib/test/test_threading.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,8 @@ def test_3_join_in_forked_from_thread(self):
471471
return
472472
# Skip platforms with known problems forking from a worker thread.
473473
# See http://bugs.python.org/issue3863.
474-
if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'os2emx'):
474+
if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5',
475+
'os2emx'):
475476
print >>sys.stderr, ('Skipping test_3_join_in_forked_from_thread'
476477
' due to known OS bugs on'), sys.platform
477478
return

Modules/_multiprocessing/multiprocessing.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,19 @@ init_multiprocessing(void)
256256
if (PyType_Ready(&SemLockType) < 0)
257257
return;
258258
Py_INCREF(&SemLockType);
259-
PyDict_SetItemString(SemLockType.tp_dict, "SEM_VALUE_MAX",
260-
Py_BuildValue("i", SEM_VALUE_MAX));
259+
{
260+
PyObject *py_sem_value_max;
261+
/* Some systems define SEM_VALUE_MAX as an unsigned value that
262+
* causes it to be negative when used as an int (NetBSD). */
263+
if ((int)(SEM_VALUE_MAX) < 0)
264+
py_sem_value_max = PyLong_FromLong(INT_MAX);
265+
else
266+
py_sem_value_max = PyLong_FromLong(SEM_VALUE_MAX);
267+
if (py_sem_value_max == NULL)
268+
return NULL;
269+
PyDict_SetItemString(SemLockType.tp_dict, "SEM_VALUE_MAX",
270+
py_sem_value_max);
271+
}
261272
PyModule_AddObject(module, "SemLock", (PyObject*)&SemLockType);
262273
#endif
263274

Modules/socketmodule.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
379379
#define SOCKETCLOSE close
380380
#endif
381381

382-
#if (defined(HAVE_BLUETOOTH_H) || defined(HAVE_BLUETOOTH_BLUETOOTH_H)) && !defined(__NetBSD__)
382+
#if (defined(HAVE_BLUETOOTH_H) || defined(HAVE_BLUETOOTH_BLUETOOTH_H)) && !defined(__NetBSD__) && !defined(__DragonFly__)
383383
#define USE_BLUETOOTH 1
384384
#if defined(__FreeBSD__)
385385
#define BTPROTO_L2CAP BLUETOOTH_PROTO_L2CAP
@@ -393,11 +393,13 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
393393
#define _BT_L2_MEMB(sa, memb) ((sa)->l2cap_##memb)
394394
#define _BT_RC_MEMB(sa, memb) ((sa)->rfcomm_##memb)
395395
#define _BT_HCI_MEMB(sa, memb) ((sa)->hci_##memb)
396-
#elif defined(__NetBSD__)
396+
#elif defined(__NetBSD__) || defined(__DragonFly__)
397397
#define sockaddr_l2 sockaddr_bt
398398
#define sockaddr_rc sockaddr_bt
399399
#define sockaddr_hci sockaddr_bt
400400
#define sockaddr_sco sockaddr_bt
401+
#define SOL_HCI BTPROTO_HCI
402+
#define HCI_DATA_DIR SO_HCI_DIRECTION
401403
#define _BT_L2_MEMB(sa, memb) ((sa)->bt_##memb)
402404
#define _BT_RC_MEMB(sa, memb) ((sa)->bt_##memb)
403405
#define _BT_HCI_MEMB(sa, memb) ((sa)->bt_##memb)
@@ -1076,9 +1078,13 @@ makesockaddr(int sockfd, struct sockaddr *addr, int addrlen, int proto)
10761078
case BTPROTO_HCI:
10771079
{
10781080
struct sockaddr_hci *a = (struct sockaddr_hci *) addr;
1081+
#if defined(__NetBSD__) || defined(__DragonFly__)
1082+
return makebdaddr(&_BT_HCI_MEMB(a, bdaddr));
1083+
#else
10791084
PyObject *ret = NULL;
10801085
ret = Py_BuildValue("i", _BT_HCI_MEMB(a, dev));
10811086
return ret;
1087+
#endif
10821088
}
10831089

10841090
#if !defined(__FreeBSD__)
@@ -1362,12 +1368,25 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
13621368
case BTPROTO_HCI:
13631369
{
13641370
struct sockaddr_hci *addr = (struct sockaddr_hci *)addr_ret;
1371+
#if defined(__NetBSD__) || defined(__DragonFly__)
1372+
char *straddr = PyBytes_AS_STRING(args);
1373+
1374+
_BT_HCI_MEMB(addr, family) = AF_BLUETOOTH;
1375+
if (straddr == NULL) {
1376+
PyErr_SetString(socket_error, "getsockaddrarg: "
1377+
"wrong format");
1378+
return 0;
1379+
}
1380+
if (setbdaddr(straddr, &_BT_HCI_MEMB(addr, bdaddr)) < 0)
1381+
return 0;
1382+
#else
13651383
_BT_HCI_MEMB(addr, family) = AF_BLUETOOTH;
13661384
if (!PyArg_ParseTuple(args, "i", &_BT_HCI_MEMB(addr, dev))) {
13671385
PyErr_SetString(socket_error, "getsockaddrarg: "
13681386
"wrong format");
13691387
return 0;
13701388
}
1389+
#endif
13711390
*len_ret = sizeof *addr;
13721391
return 1;
13731392
}
@@ -4644,9 +4663,13 @@ init_socket(void)
46444663
PyModule_AddIntConstant(m, "BTPROTO_L2CAP", BTPROTO_L2CAP);
46454664
PyModule_AddIntConstant(m, "BTPROTO_HCI", BTPROTO_HCI);
46464665
PyModule_AddIntConstant(m, "SOL_HCI", SOL_HCI);
4666+
#if !defined(__NetBSD__) && !defined(__DragonFly__)
46474667
PyModule_AddIntConstant(m, "HCI_FILTER", HCI_FILTER);
4668+
#endif
46484669
#if !defined(__FreeBSD__)
4670+
#if !defined(__NetBSD__) && !defined(__DragonFly__)
46494671
PyModule_AddIntConstant(m, "HCI_TIME_STAMP", HCI_TIME_STAMP);
4672+
#endif
46504673
PyModule_AddIntConstant(m, "HCI_DATA_DIR", HCI_DATA_DIR);
46514674
PyModule_AddIntConstant(m, "BTPROTO_SCO", BTPROTO_SCO);
46524675
#endif

0 commit comments

Comments
 (0)