Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 397cd8a

Browse files
committed
Merged revisions 85586-85587,85596-85598 via svnmerge from
svn+ssh://[email protected]/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 67295c3 commit 397cd8a

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
@@ -459,7 +459,8 @@ def test_3_join_in_forked_from_thread(self):
459459
return
460460
# Skip platforms with known problems forking from a worker thread.
461461
# See http://bugs.python.org/issue3863.
462-
if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'os2emx'):
462+
if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'netbsd5',
463+
'os2emx'):
463464
print('Skipping test_3_join_in_forked_from_thread'
464465
' due to known OS bugs on', sys.platform, file=sys.stderr)
465466
return

Modules/_multiprocessing/multiprocessing.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,19 @@ PyInit__multiprocessing(void)
269269
if (PyType_Ready(&SemLockType) < 0)
270270
return NULL;
271271
Py_INCREF(&SemLockType);
272-
PyDict_SetItemString(SemLockType.tp_dict, "SEM_VALUE_MAX",
273-
Py_BuildValue("i", SEM_VALUE_MAX));
272+
{
273+
PyObject *py_sem_value_max;
274+
/* Some systems define SEM_VALUE_MAX as an unsigned value that
275+
* causes it to be negative when used as an int (NetBSD). */
276+
if ((int)(SEM_VALUE_MAX) < 0)
277+
py_sem_value_max = PyLong_FromLong(INT_MAX);
278+
else
279+
py_sem_value_max = PyLong_FromLong(SEM_VALUE_MAX);
280+
if (py_sem_value_max == NULL)
281+
return NULL;
282+
PyDict_SetItemString(SemLockType.tp_dict, "SEM_VALUE_MAX",
283+
py_sem_value_max);
284+
}
274285
PyModule_AddObject(module, "SemLock", (PyObject*)&SemLockType);
275286
#endif
276287

Modules/socketmodule.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ dup_socket(SOCKET handle)
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 @@ dup_socket(SOCKET handle)
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)
@@ -1039,9 +1041,13 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
10391041
case BTPROTO_HCI:
10401042
{
10411043
struct sockaddr_hci *a = (struct sockaddr_hci *) addr;
1044+
#if defined(__NetBSD__) || defined(__DragonFly__)
1045+
return makebdaddr(&_BT_HCI_MEMB(a, bdaddr));
1046+
#else
10421047
PyObject *ret = NULL;
10431048
ret = Py_BuildValue("i", _BT_HCI_MEMB(a, dev));
10441049
return ret;
1050+
#endif
10451051
}
10461052

10471053
#if !defined(__FreeBSD__)
@@ -1325,12 +1331,25 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
13251331
case BTPROTO_HCI:
13261332
{
13271333
struct sockaddr_hci *addr = (struct sockaddr_hci *)addr_ret;
1334+
#if defined(__NetBSD__) || defined(__DragonFly__)
1335+
char *straddr = PyBytes_AS_STRING(args);
1336+
1337+
_BT_HCI_MEMB(addr, family) = AF_BLUETOOTH;
1338+
if (straddr == NULL) {
1339+
PyErr_SetString(socket_error, "getsockaddrarg: "
1340+
"wrong format");
1341+
return 0;
1342+
}
1343+
if (setbdaddr(straddr, &_BT_HCI_MEMB(addr, bdaddr)) < 0)
1344+
return 0;
1345+
#else
13281346
_BT_HCI_MEMB(addr, family) = AF_BLUETOOTH;
13291347
if (!PyArg_ParseTuple(args, "i", &_BT_HCI_MEMB(addr, dev))) {
13301348
PyErr_SetString(socket_error, "getsockaddrarg: "
13311349
"wrong format");
13321350
return 0;
13331351
}
1352+
#endif
13341353
*len_ret = sizeof *addr;
13351354
return 1;
13361355
}
@@ -4400,9 +4419,13 @@ PyInit__socket(void)
44004419
PyModule_AddIntConstant(m, "BTPROTO_L2CAP", BTPROTO_L2CAP);
44014420
PyModule_AddIntConstant(m, "BTPROTO_HCI", BTPROTO_HCI);
44024421
PyModule_AddIntConstant(m, "SOL_HCI", SOL_HCI);
4422+
#if !defined(__NetBSD__) && !defined(__DragonFly__)
44034423
PyModule_AddIntConstant(m, "HCI_FILTER", HCI_FILTER);
4424+
#endif
44044425
#if !defined(__FreeBSD__)
4426+
#if !defined(__NetBSD__) && !defined(__DragonFly__)
44054427
PyModule_AddIntConstant(m, "HCI_TIME_STAMP", HCI_TIME_STAMP);
4428+
#endif
44064429
PyModule_AddIntConstant(m, "HCI_DATA_DIR", HCI_DATA_DIR);
44074430
PyModule_AddIntConstant(m, "BTPROTO_SCO", BTPROTO_SCO);
44084431
#endif

0 commit comments

Comments
 (0)