- add scsi_commands.h for Amiga CDROM support, from Nicholai Benalal   <nicholai@chello.se>

error: pathspec 'iodev/scsi_commands.h' did not match any file(s) known to git

--- iodev/scsi_commands.h
+++ iodev/scsi_commands.h
@@ -0,0 +1,413 @@
+/* scsi/commands.h
+
+	Operation codes for SCSI-2 commands
+
+   30 Nov 94   Peter Urbanec    Created file
+   10 Jan 95   Peter Urbanec    Added SCSI_ prefix to all commands
+   31 Jan 95   Peter Urbanec    Released to public
+
+*/
+
+
+/* All device types */
+
+#define SCSI_CHANGE_DEFINITION			0x40
+#define SCSI_COMPARE				0x39
+#define SCSI_COPY				0x18
+#define SCSI_COPY_AND_VERIFY			0x3a
+#define SCSI_INQUIRY				0x12
+#define SCSI_LOG_SELECT				0x4c
+#define SCSI_LOG_SENSE				0x4d
+#define SCSI_MODE_SELECT_6			0x15
+#define SCSI_MODE_SELECT_10			0x55
+#define SCSI_MODE_SENSE_6			0x1a
+#define SCSI_MODE_SENSE_10			0x5a
+#define SCSI_READ_BUFFER			0x3c
+#define SCSI_RECEIVE_DIAGNOSTIC_RESULTS		0x1c
+#define SCSI_REQUEST_SENSE			0x03
+#define SCSI_SEND_DIAGNOSTIC			0x1d
+#define SCSI_TEST_UNIT_READY			0x00
+#define SCSI_WRITE_BUFFER			0x3b
+
+
+/* Direct Access devices */
+
+#define SCSI_DA_CHANGE_DEFINITION		0x40
+#define SCSI_DA_COMPARE				0x39
+#define SCSI_DA_COPY				0x18
+#define SCSI_DA_COPY_AND_VERIFY			0x3a
+#define SCSI_DA_FORMAT_UNIT			0x04
+#define SCSI_DA_INQUIRY				0x12
+#define SCSI_DA_LOCK_UNLOCK_CACHE		0x36
+#define SCSI_DA_LOG_SELECT			0x4c
+#define SCSI_DA_LOG_SENSE			0x4d
+#define SCSI_DA_MODE_SELECT_6			0x15
+#define SCSI_DA_MODE_SELECT_10			0x55
+#define SCSI_DA_MODE_SENSE_6			0x1a
+#define SCSI_DA_MODE_SENSE_10			0x5a
+#define SCSI_DA_PRE_FETCH			0x34
+#define SCSI_DA_PREVENT_ALLOW_MEDIUM_REMOVAL	0x1e
+#define SCSI_DA_READ_6				0x08
+#define SCSI_DA_READ_10				0x28
+#define SCSI_DA_READ_BUFFER			0x3c
+#define SCSI_DA_READ_CAPACITY			0x25
+#define SCSI_DA_READ_DEFECT_DATA		0x37
+#define SCSI_DA_READ_LONG			0x3e
+#define SCSI_DA_REASSIGN_BLOCKS			0x07
+#define SCSI_DA_RECEIVE_DIAGNOSTIC_RESULTS	0x1c
+#define SCSI_DA_RELEASE				0x17
+#define SCSI_DA_REQUEST_SENSE			0x03
+#define SCSI_DA_RESERVE				0x16
+#define SCSI_DA_REZERO_UNIT			0x01
+#define SCSI_DA_SEARCH_DATA_EQUAL		0x31
+#define SCSI_DA_SEARCH_DATA_HIGH		0x30
+#define SCSI_DA_SEARCH_DATA_LOW			0x32
+#define SCSI_DA_SEEK_6				0x0b
+#define SCSI_DA_SEEK_10				0x2b
+#define SCSI_DA_SEND_DIAGNOSTIC			0x1d
+#define SCSI_DA_SET_LIMITS			0x33
+#define SCSI_DA_START_STOP_UNIT			0x1b
+#define SCSI_DA_SYNCHRONIZE_CACHE		0x35
+#define SCSI_DA_TEST_UNIT_READY			0x00
+#define SCSI_DA_VERIFY				0x2f
+
+
+/* Sequential access devices */
+
+#define SCSI_SA_CHANGE_DEFINITION		0x40
+#define SCSI_SA_COMPARE				0x39
+#define SCSI_SA_COPY				0x18
+#define SCSI_SA_COPY_AND_VERIFY			0x3a
+#define SCSI_SA_ERASE				0x19
+#define SCSI_SA_INQUIRY				0x12
+#define SCSI_SA_LOAD_UNLOAD			0x1b
+#define SCSI_SA_LOCATE				0x2b
+#define SCSI_SA_LOG_SELECT			0x4c
+#define SCSI_SA_LOG_SENSE			0x4d
+#define SCSI_SA_MODE_SELECT_6			0x15
+#define SCSI_SA_MODE_SELECT_10			0x55
+#define SCSI_SA_MODE_SENSE_6			0x1a
+#define SCSI_SA_MODE_SENSE_10			0x5a
+#define SCSI_SA_PREVENT_ALLOW_MEDIUM_REMOVAL	0x1e
+#define SCSI_SA_READ				0x08
+#define SCSI_SA_READ_BLOCK_LIMITS		0x05
+#define SCSI_SA_READ_BUFFER			0x3c
+#define SCSI_SA_READ_POSITION			0x34
+#define SCSI_SA_READ_REVERSE			0x0f
+#define SCSI_SA_RECEIVE_DIAGNOSTIC_RESULTS	0x1c
+#define SCSI_SA_RECOVER_BUFFERED_DATA		0x14
+#define SCSI_SA_RELEASE_UNIT			0x17
+#define SCSI_SA_REQUEST_SENSE			0x03
+#define SCSI_SA_RESERVE_UNIT			0x16
+#define SCSI_SA_REWIND				0x01
+#define SCSI_SA_SEND_DIAGNOSTIC			0x1d
+#define SCSI_SA_SPACE				0x11
+#define SCSI_SA_TEST_UNIT_READY			0x00
+#define SCSI_SA_VERIFY				0x13
+#define SCSI_SA_WRITE				0x0a
+#define SCSI_SA_WRITE_BUFFER			0x3b
+#define SCSI_SA_WRITE_FILEMARKS			0x10
+
+
+/* Printer devices */
+
+#define SCSI_PRT_CHANGE_DEFINITION		0x40
+#define SCSI_PRT_COMPARE			0x39
+#define SCSI_PRT_COPY				0x18
+#define SCSI_PRT_COPY_AND_VERIFY		0x3a
+#define SCSI_PRT_FORMAT				0x04
+#define SCSI_PRT_INQUIRY			0x12
+#define SCSI_PRT_LOG_SELECT			0x4c
+#define SCSI_PRT_LOG_SENSE			0x4d
+#define SCSI_PRT_MODE_SELECT_6			0x15
+#define SCSI_PRT_MODE_SELECT_10			0x55
+#define SCSI_PRT_MODE_SENSE_6			0x1a
+#define SCSI_PRT_MODE_SENSE_10			0x5a
+#define SCSI_PRT_PRINT				0x0a
+#define SCSI_PRT_READ_BUFFER			0x3c
+#define SCSI_PRT_RECEIVE_DIAGNOSTIC_RESULTS	0x1c
+#define SCSI_PRT_RECOVER_BUFFERED_DATA		0x14
+#define SCSI_PRT_RELEASE_UNIT			0x17
+#define SCSI_PRT_REQUEST_SENSE			0x03
+#define SCSI_PRT_RESERVE_UNIT			0x16
+#define SCSI_PRT_SEND_DIAGNOSTIC		0x1d
+#define SCSI_PRT_SLEW_AND_PRINT			0x0b
+#define SCSI_PRT_STOP_PRINT			0x1b
+#define SCSI_PRT_SYNCHRONIZE_BUFFER		0x10
+#define SCSI_PRT_TEST_UNIT_READY		0x00
+#define SCSI_PRT_WRITE_BUFFER			0x3b
+
+
+/* Processor devices */
+
+#define SCSI_CPU_CHANGE_DEFINITION		0x40
+#define SCSI_CPU_COMPARE			0x39
+#define SCSI_CPU_COPY				0x18
+#define SCSI_CPU_COPY_AND_VERIFY		0x3a
+#define SCSI_CPU_INQUIRY			0x12
+#define SCSI_CPU_LOG_SELECT			0x4c
+#define SCSI_CPU_LOG_SENSE			0x4d
+#define SCSI_CPU_READ_BUFFER			0x3c
+#define SCSI_CPU_RECEIVE			0x08
+#define SCSI_CPU_RECEIVE_DIAGNOSTIC_RESULTS	0x1c
+#define SCSI_CPU_REQUEST_SENSE			0x03
+#define SCSI_CPU_SEND				0x0a
+#define SCSI_CPU_SEND_DIAGNOSTIC		0x1d
+#define SCSI_CPU_TEST_UNIT_READY		0x00
+#define SCSI_CPU_WRITE_BUFFER			0x3b
+
+
+/* Write Once devices */
+
+#define SCSI_WO_CHANGE_DEFINITION		0x40
+#define SCSI_WO_COMPARE				0x39
+#define SCSI_WO_COPY				0x18
+#define SCSI_WO_COPY_AND_VERIFY			0x3a
+#define SCSI_WO_INQUIRY				0x12
+#define SCSI_WO_LOCK_UNLOCK_CACHE		0x36
+#define SCSI_WO_LOG_SELECT			0x4c
+#define SCSI_WO_LOG_SENSE			0x4d
+#define SCSI_WO_MEDIUM_SCAN			0x38
+#define SCSI_WO_MODE_SELECT_6			0x15
+#define SCSI_WO_MODE_SELECT_10			0x55
+#define SCSI_WO_MODE_SENSE_6			0x1a
+#define SCSI_WO_MODE_SENSE_10			0x5a
+#define SCSI_WO_PRE_FETCH			0x34
+#define SCSI_WO_PREVENT_ALLOW_MEDIUM_REMOVAL	0x1e
+#define SCSI_WO_READ_6				0x08
+#define SCSI_WO_READ_10				0x28
+#define SCSI_WO_READ_12				0xa8
+#define SCSI_WO_READ_BUFFER			0x3c
+#define SCSI_WO_READ_CAPACITY			0x25
+#define SCSI_WO_READ_LONG			0x3e
+#define SCSI_WO_REASSIGN_BLOCKS			0x07
+#define SCSI_WO_RECEIVE_DIAGNOSTIC_RESULTS	0x1c
+#define SCSI_WO_RELEASE				0x17
+#define SCSI_WO_REQUEST_SENSE			0x03
+#define SCSI_WO_RESERVE				0x16
+#define SCSI_WO_REZERO_UNIT			0x01
+#define SCSI_WO_SEARCH_DATA_EQUAL_10		0x31
+#define SCSI_WO_SEARCH_DATA_EQUAL_12		0xb1
+#define SCSI_WO_SEARCH_DATA_HIGH_10		0x30
+#define SCSI_WO_SEARCH_DATA_HIGH_12		0xb0
+#define SCSI_WO_SEARCH_DATA_LOW_10		0x32
+#define SCSI_WO_SEARCH_DATA_LOW_12		0xb2
+#define SCSI_WO_SEEK_6				0x0b
+#define SCSI_WO_SEEK_10				0x2b
+#define SCSI_WO_SEND_DIAGNOSTIC			0x1d
+#define SCSI_WO_SET_LIMITS_10			0x33
+#define SCSI_WO_SET_LIMITS_12			0xb3
+#define SCSI_WO_START_STOP_UNIT			0x1b
+#define SCSI_WO_SYNCHRONIZE_CACHE		0x35
+#define SCSI_WO_TEST_UNIT_READY			0x00
+#define SCSI_WO_VERIFY_10			0x2f
+#define SCSI_WO_VERIFY_12			0xaf
+#define SCSI_WO_WRITE_6				0x0a
+#define SCSI_WO_WRITE_10			0x2a
+#define SCSI_WO_WRITE_12			0xaa
+#define SCSI_WO_WRITE_AND_VERIFY_10		0x2e
+#define SCSI_WO_WRITE_AND_VERIFY_12		0xae
+#define SCSI_WO_WRITE_BUFFER			0x3b
+#define SCSI_WO_WRITE_LONG			0x3f
+
+
+/* CD-ROM devices */
+
+#define SCSI_CD_CHANGE_DEFINITION		0x40
+#define SCSI_CD_COMPARE				0x39
+#define SCSI_CD_COPY				0x18
+#define SCSI_CD_COPY_AND_VERIFY			0x3a
+#define SCSI_CD_INQUIRY				0x12
+#define SCSI_CD_LOCK_UNLOCK_CACHE		0x36
+#define SCSI_CD_LOG_SELECT			0x4c
+#define SCSI_CD_LOG_SENSE			0x4d
+#define SCSI_CD_MODE_SELECT_6			0x15
+#define SCSI_CD_MODE_SELECT_10			0x55
+#define SCSI_CD_MODE_SENSE_6			0x1a
+#define SCSI_CD_MODE_SENSE_10			0x5a
+#define SCSI_CD_PAUSE_RESUME			0x4b
+#define SCSI_CD_PLAY_AUDIO_10			0x45
+#define SCSI_CD_PLAY_AUDIO_12			0xa5
+#define SCSI_CD_PLAY_AUDIO_MSF			0x47
+#define SCSI_CD_PLAY_AUDIO_TRACK_INDEX		0x48
+#define SCSI_CD_PLAY_TRACK_RELATIVE_10		0x49
+#define SCSI_CD_PLAY_TRACK_RELATIVE_12		0xa9
+#define SCSI_CD_PRE_FETCH			0x34
+#define SCSI_CD_PREVENT_ALLOW_MEDIUM_REMOVAL	0x1e
+#define SCSI_CD_READ_6				0x08
+#define SCSI_CD_READ_10				0x28
+#define SCSI_CD_READ_12				0xa8
+#define SCSI_CD_READ_BUFFER			0x3c
+#define SCSI_CD_READ_CD_ROM_CAPACITY		0x25
+#define SCSI_CD_READ_HEADER			0x44
+#define SCSI_CD_READ_LONG			0x3e
+#define SCSI_CD_READ_SUB_CHANNEL		0x42
+#define SCSI_CD_READ_TOC			0x43
+#define SCSI_CD_RECEIVE_DIAGNOSTIC_RESULT	0x1c
+#define SCSI_CD_RELEASE				0x17
+#define SCSI_CD_REQUEST_SENSE			0x03
+#define SCSI_CD_RESERVE				0x16
+#define SCSI_CD_REZERO_UNIT			0x01
+#define SCSI_CD_SEARCH_DATA_EQUAL_10		0x31
+#define SCSI_CD_SEARCH_DATA_EQUAL_12		0xb1
+#define SCSI_CD_SEARCH_DATA_HIGH_10		0x30
+#define SCSI_CD_SEARCH_DATA_HIGH_12		0xb0
+#define SCSI_CD_SEARCH_DATA_LOW_10		0x32
+#define SCSI_CD_SEARCH_DATA_LOW_12		0xb2
+#define SCSI_CD_SEEK_6				0x0b
+#define SCSI_CD_SEEK_10				0x2b
+#define SCSI_CD_SEND_DIAGNOSTIC			0x1d
+#define SCSI_CD_SET_LIMITS_10			0x33
+#define SCSI_CD_SET_LIMITS_12			0xb3
+#define SCSI_CD_START_STOP_UNIT			0x1b
+#define SCSI_CD_SYNCHRONIZE_CACHE		0x35
+#define SCSI_CD_TEST_UNIT_READY			0x00
+#define SCSI_CD_VERIFY_10			0x2f
+#define SCSI_CD_VERIFY_12			0xaf
+#define SCSI_CD_WRITE_BUFFER			0x3b
+
+
+/* Scanner devices */
+
+#define SCSI_SC_CHANGE_DEFINITION		0x40
+#define SCSI_SC_COMPARE				0x39
+#define SCSI_SC_COPY				0x18
+#define SCSI_SC_COPY_AND_VERIFY			0x3a
+#define SCSI_SC_GET_DATA_BUFFER_STATUS		0x34
+#define SCSI_SC_GET_WINDOW			0x25
+#define SCSI_SC_INQUIRY				0x12
+#define SCSI_SC_LOG_SELECT			0x4c
+#define SCSI_SC_LOG_SENSE			0x4d
+#define SCSI_SC_MODE_SELECT_6			0x15
+#define SCSI_SC_MODE_SELECT_10			0x55
+#define SCSI_SC_MODE_SENSE_6			0x1a
+#define SCSI_SC_MODE_SENSE_10			0x5a
+#define SCSI_SC_OBJECT_POSITION			0x31
+#define SCSI_SC_READ				0x28
+#define SCSI_SC_READ_BUFFER			0x3c
+#define SCSI_SC_RECEIVE_DIAGNOSTIC_RESULTS	0x1c
+#define SCSI_SC_RELEASE_UNIT			0x17
+#define SCSI_SC_REQUEST_SENSE			0x03
+#define SCSI_SC_RESERVE_UNIT			0x16
+#define SCSI_SC_SCAN				0x1b
+#define SCSI_SC_SET_WINDOW			0x24
+#define SCSI_SC_SEND				0x2a
+#define SCSI_SC_SEND_DIAGNOSTIC			0x1d
+#define SCSI_SC_TEST_UNIT_READY			0x00
+#define SCSI_SC_WRITE_BUFFER			0x3b
+
+
+/* Optical memory devices */
+
+#define SCSI_OM_CHANGE_DEFINITION		0x40
+#define SCSI_OM_COMPARE				0x39
+#define SCSI_OM_COPY				0x18
+#define SCSI_OM_COPY_AND_VERIFY			0x3a
+#define SCSI_OM_ERASE_10			0x2c
+#define SCSI_OM_ERASE_12			0xac
+#define SCSI_OM_FORMAT_UNIT			0x04
+#define SCSI_OM_INQUIRY				0x12
+#define SCSI_OM_LOCK_UNLOCK_CACHE		0x36
+#define SCSI_OM_LOG_SELECT			0x4c
+#define SCSI_OM_LOG_SENSE			0x4d
+#define SCSI_OM_MEDIUM_SCAN			0x38
+#define SCSI_OM_MODE_SELECT_6			0x15
+#define SCSI_OM_MODE_SELECT_10			0x55
+#define SCSI_OM_MODE_SENSE_6			0x1a
+#define SCSI_OM_MODE_SENSE_10			0x5a
+#define SCSI_OM_PRE_FETCH			0x34
+#define SCSI_OM_PREVENT_ALLOW_MEDIUM_REMOVAL	0x1e
+#define SCSI_OM_READ_6				0x08
+#define SCSI_OM_READ_10				0x28
+#define SCSI_OM_READ_12				0xa8
+#define SCSI_OM_READ_BUFFER			0x3c
+#define SCSI_OM_READ_CAPACITY			0x25
+#define SCSI_OM_READ_DEFECT_DATA_10		0x37
+#define SCSI_OM_READ_DEFECT_DATA_12		0xb7
+#define SCSI_OM_READ_GENERATION			0x29
+#define SCSI_OM_READ_LONG			0x3e
+#define SCSI_OM_READ_UPDATED_BLOCK		0x2d
+#define SCSI_OM_REASSIGN_BLOCKS			0x07
+#define SCSI_OM_RECEIVE_DIAGNOSTIC_RESULTS	0x1c
+#define SCSI_OM_RELEASE				0x17
+#define SCSI_OM_REQUEST_SENSE			0x03
+#define SCSI_OM_RESERVE				0x16
+#define SCSI_OM_REZERO_UNIT			0x01
+#define SCSI_OM_SEARCH_DATA_EQUAL_10		0x31
+#define SCSI_OM_SEARCH_DATA_EQUAL_12		0xb1
+#define SCSI_OM_SEARCH_DATA_HIGH_10		0x30
+#define SCSI_OM_SEARCH_DATA_HIGH_12		0xb0
+#define SCSI_OM_SEARCH_DATA_LOW_10		0x32
+#define SCSI_OM_SEARCH_DATA_LOW_12		0xb2
+#define SCSI_OM_SEEK_6				0x0b
+#define SCSI_OM_SEEK_10				0x2b
+#define SCSI_OM_SEND_DIAGNOSTIC			0x1d
+#define SCSI_OM_SET_LIMITS_10			0x33
+#define SCSI_OM_SET_LIMITS_12			0xb3
+#define SCSI_OM_START_STOP_UNIT			0x1b
+#define SCSI_OM_SYNCHRONIZE_CACHE		0x35
+#define SCSI_OM_TEST_UNIT_READY			0x00
+#define SCSI_OM_UPDATE_BLOCK			0x3d
+#define SCSI_OM_VERIFY_10			0x2f
+#define SCSI_OM_VERIFY_12			0xaf
+#define SCSI_OM_WRITE_6				0x0a
+#define SCSI_OM_WRITE_10			0x2a
+#define SCSI_OM_WRITE_12			0xaa
+#define SCSI_OM_WRITE_AND_VERIFY_10		0x2e
+#define SCSI_OM_WRITE_AND_VERIFY_12		0xae
+#define SCSI_OM_WRITE_BUFFER			0x3b
+#define SCSI_OM_WRITE_LONG			0x3f
+
+
+/* Medium changer devices */
+
+#define SCSI_MC_CHANGE_DEFINITION		0x40
+#define SCSI_MC_EXCHANGE_MEDIUM			0xa6
+#define SCSI_MC_INITIALIZE_ELEMENT_STATUS	0x07
+#define SCSI_MC_INQUIRY				0x12
+#define SCSI_MC_LOG_SELECT			0x4c
+#define SCSI_MC_LOG_SENSE			0x4d
+#define SCSI_MC_MODE_SELECT_6			0x15
+#define SCSI_MC_MODE_SELECT_10			0x55
+#define SCSI_MC_MODE_SENSE_6			0x1a
+#define SCSI_MC_MODE_SENSE_10			0x5a
+#define SCSI_MC_MOVE_MEDIUM			0xa5
+#define SCSI_MC_POSITION_TO_ELEMENT		0x2b
+#define SCSI_MC_PREVENT_ALLOW_MEDIUM_REMOVAL	0x1e
+#define SCSI_MC_READ_BUFFER			0x3c
+#define SCSI_MC_READ_ELEMENT_STATUS		0xb8
+#define SCSI_MC_RECEIVE_DIAGNOSTIC_RESULTS	0x1c
+#define SCSI_MC_RELEASE				0x17
+#define SCSI_MC_REQUEST_VOLUME_ELEMENT_ADDRESS	0xb5
+#define SCSI_MC_REQUEST_SENSE			0x03
+#define SCSI_MC_RESERVE				0x16
+#define SCSI_MC_REZERO_UNIT			0x01
+#define SCSI_MC_SEND_DIAGNOSTIC			0x1d
+#define SCSI_MC_SEND_VOLUME_TAG			0xb6
+#define SCSI_MC_TEST_UNIT_READY			0x00
+#define SCSI_MC_WRITE_BUFFER			0x3b
+
+
+/* Communications devices */
+
+#define SCSI_COM_CHANGE_DEFINITION		0x40
+#define SCSI_COM_GET_MESSAGE_6			0x08
+#define SCSI_COM_GET_MESSAGE_10			0x28
+#define SCSI_COM_GET_MESSAGE_12			0xa8
+#define SCSI_COM_INQUIRY			0x12
+#define SCSI_COM_LOG_SELECT			0x4c
+#define SCSI_COM_LOG_SENSE			0x4d
+#define SCSI_COM_MODE_SELECT_6			0x15
+#define SCSI_COM_MODE_SELECT_10			0x55
+#define SCSI_COM_MODE_SENSE_6			0x1a
+#define SCSI_COM_MODE_SENSE_10			0x5a
+#define SCSI_COM_READ_BUFFER			0x3c
+#define SCSI_COM_RECEIVE_DIAGNOSTIC_RESULTS	0x1c
+#define SCSI_COM_REQUEST_SENSE			0x03
+#define SCSI_COM_SEND_DIAGNOSTIC		0x1d
+#define SCSI_COM_SEND_MESSAGE_6			0x0a
+#define SCSI_COM_SEND_MESSAGE_10		0x2a
+#define SCSI_COM_SEND_MESSAGE_12		0xaa
+#define SCSI_COM_TEST_UNIT_READY		0x00
+#define SCSI_COM_WRITE_BUFFER			0x3b
+


Ignore guest PAT settings by default in EPT mappings.
From experimentation, other hypervisors also do this.

Diagnosed by:	tycho nightingale at pluribusnetworks com
Reviewed by:	neel


Fix crash in atspi_image_get_image_description

If the remote object didn't define this property then the function
would return stack garbage, which the caller would eventually try to
free.

https://bugzilla.gnome.org/show_bug.cgi?id=640198

--- atspi/atspi-image.c
+++ atspi/atspi-image.c
@@ -34,7 +34,7 @@
 gchar *
 atspi_image_get_image_description (AtspiImage *obj, GError **error)
 {
-  char *retval;
+  char *retval = NULL;

   g_return_val_if_fail (obj != NULL, NULL);


Ensured that all branches of MatrixLogarithmAtomic::getPadeDegree return values.

--- unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h
+++ unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h
@@ -172,10 +172,11 @@
 {
   const float maxNormForPade[] = { 2.5111573934555054e-1 /* degree = 3 */ , 4.0535837411880493e-1,
             5.3149729967117310e-1 };
-  for (int degree = 3; degree <= maxPadeDegree; ++degree)
+  int degree = 3
+  for (; degree <= maxPadeDegree; ++degree)
     if (normTminusI <= maxNormForPade[degree - minPadeDegree])
-      return degree;
-  assert(false); // this line should never be reached
+      break;
+  return degree;
 }

 /* \brief Get suitable degree for Pade approximation. (specialized for RealScalar = double) */
@@ -184,10 +185,11 @@
 {
   const double maxNormForPade[] = { 1.6206284795015624e-2 /* degree = 3 */ , 5.3873532631381171e-2,
             1.1352802267628681e-1, 1.8662860613541288e-1, 2.642960831111435e-1 };
-  for (int degree = 3; degree <= maxPadeDegree; ++degree)
+  int degree = 3;
+  for (; degree <= maxPadeDegree; ++degree)
     if (normTminusI <= maxNormForPade[degree - minPadeDegree])
-      return degree;
-  assert(false); // this line should never be reached
+      break;
+  return degree;
 }

 /* \brief Get suitable degree for Pade approximation. (specialized for RealScalar = long double) */
@@ -214,10 +216,11 @@
             3.6688019729653446926585242192447447e-2, 5.9290962294020186998954055264528393e-2,
             8.6998436081634343903250580992127677e-2, 1.1880960220216759245467951592883642e-1 };
 #endif
-  for (int degree = 3; degree <= maxPadeDegree; ++degree)
+  int degree = 3
+  for (; degree <= maxPadeDegree; ++degree)
     if (normTminusI <= maxNormForPade[degree - minPadeDegree])
-      return degree;
-  assert(false); // this line should never be reached
+      break;
+  return degree;
 }

 /* \brief Compute Pade approximation to matrix logarithm */


Remove an ifdef that's been here for a long time.  So long, in fact,
that it references a function parameter that's not been passed in for
more than 4 years.

This has been if 0'd since 1994.

--- sys/dev/ed/if_ed_novell.c
+++ sys/dev/ed/if_ed_novell.c
@@ -165,13 +165,6 @@

 	/* 8k of memory plus an additional 8k if 16bit */
 	memsize = 8192 + sc->isa16bit * 8192;
-
-#if 0	/* probably not useful - NE boards only come two ways */
-	/* allow kernel config file overrides */
-	if (isa_dev->id_msize)
-		memsize = isa_dev->id_msize;
-#endif
-
 	sc->mem_size = memsize;

 	/* NIC memory doesn't start at zero on an NE board */


When deconfiguring a log, only stop PMCs that are in the RUNNING state.

--- sys/dev/hwpmc/hwpmc_mod.c
+++ sys/dev/hwpmc/hwpmc_mod.c
@@ -2439,7 +2439,8 @@
 			error = pmclog_flush(po);
 			if (error == 0) {
 				LIST_FOREACH(pm, &po->po_pmcs, pm_next)
-				    if (pm->pm_flags & PMC_F_NEEDS_LOGFILE)
+				    if (pm->pm_flags & PMC_F_NEEDS_LOGFILE &&
+					pm->pm_state == PMC_STATE_RUNNING)
 					    pmc_stop(pm);
 				error = pmclog_deconfigure_log(po);
 			}


Fix up ndis interaction with net80211
 - make NDIS_DEBUG a sysctl
 - default to IEEE80211_MODE_11B if the card doesnt tell us the channels
 - dont mess with ic_des_chan when we assosciate
 - Allow a directed scan by setting the ESSID before scanning (verified
   with wireshark). Hidden APs probably wouldnt have worked before.
 - Grab the channel type and use it to look up the correct curchan for
   the scan results (mistakenly used 11B before)
 - Fix memory leak in the ndis_scan_results

Tested by:	matteo
Reviewed by:	sam
Approved by:	re (rwatson)

--- sys/dev/if_ndis/if_ndis.c
+++ sys/dev/if_ndis/if_ndis.c
@@ -48,9 +48,7 @@
 #include <sys/queue.h>
 #include <sys/module.h>
 #include <sys/proc.h>
-#if __FreeBSD_version < 502113
 #include <sys/sysctl.h>
-#endif
 #include <sys/kthread.h>
 #include <sys/taskqueue.h>

@@ -89,8 +87,12 @@
 #include <compat/ndis/ndis_var.h>
 #include <dev/if_ndis/if_ndisvar.h>

+#define NDIS_DEBUG
 #ifdef NDIS_DEBUG
-#define DPRINTF(x)	printf x
+#define DPRINTF(x)	do { if (ndis_debug > 0) printf x; } while (0)
+int ndis_debug = 0;
+SYSCTL_INT(_debug, OID_AUTO, ndis, CTLFLAG_RW, &ndis_debug, 0,
+    "if_ndis debug level");
 #else
 #define DPRINTF(x)
 #endif
@@ -150,6 +152,8 @@
 static int ndis_80211_ioctl_set	(struct ifnet *, u_long, caddr_t);
 static int ndis_newstate	(struct ieee80211com *, enum ieee80211_state,
 	int);
+static int ndis_nettype_chan	(uint32_t);
+static int ndis_nettype_mode	(uint32_t);
 static void ndis_scan		(void *, int);
 static void ndis_scan_results	(struct ndis_softc *);
 static void ndis_scan_start	(struct ieee80211com *);
@@ -487,6 +491,32 @@
 	return(0);
 }

+static int
+ndis_nettype_chan(uint32_t type)
+{
+	switch (type) {
+	case NDIS_80211_NETTYPE_11FH:		return (IEEE80211_CHAN_FHSS);
+	case NDIS_80211_NETTYPE_11DS:		return (IEEE80211_CHAN_B);
+	case NDIS_80211_NETTYPE_11OFDM5:	return (IEEE80211_CHAN_A);
+	case NDIS_80211_NETTYPE_11OFDM24:	return (IEEE80211_CHAN_G);
+	}
+	DPRINTF(("unknown channel nettype %d\n", type));
+	return (IEEE80211_CHAN_B);	/* Default to 11B chan */
+}
+
+static int
+ndis_nettype_mode(uint32_t type)
+{
+	switch (type) {
+	case NDIS_80211_NETTYPE_11FH:		return (IEEE80211_MODE_FH);
+	case NDIS_80211_NETTYPE_11DS:		return (IEEE80211_MODE_11B);
+	case NDIS_80211_NETTYPE_11OFDM5:	return (IEEE80211_MODE_11A);
+	case NDIS_80211_NETTYPE_11OFDM24:	return (IEEE80211_MODE_11G);
+	}
+	DPRINTF(("unknown mode nettype %d\n", type));
+	return (IEEE80211_MODE_AUTO);
+}
+
 /*
  * Attach the interface. Allocate softc structures, do ifmedia
  * setup and ethernet/BPF attach.
@@ -500,7 +530,7 @@
 	driver_object		*pdrv;
 	device_object		*pdo;
 	struct ifnet		*ifp = NULL;
-	int			error = 0, len, bands = 0;
+	int			error = 0, len, mode, bands = 0;
 	int			i;

 	sc = device_get_softc(dev);
@@ -737,26 +767,21 @@
 		}

 		for (i = 0; i < ntl->ntl_items; i++) {
-			switch (ntl->ntl_type[i]) {
-			case NDIS_80211_NETTYPE_11FH:
-			case NDIS_80211_NETTYPE_11DS:
-				setbit(ic->ic_modecaps, IEEE80211_MODE_11B);
-				setbit(&bands, IEEE80211_MODE_11B);
-				break;
-			case NDIS_80211_NETTYPE_11OFDM5:
-				setbit(ic->ic_modecaps, IEEE80211_MODE_11A);
-				setbit(&bands, IEEE80211_MODE_11A);
-				break;
-			case NDIS_80211_NETTYPE_11OFDM24:
-				setbit(ic->ic_modecaps, IEEE80211_MODE_11G);
-				setbit(&bands, IEEE80211_MODE_11G);
-				break;
-			default:
-				break;
-			}
+			mode = ndis_nettype_mode(ntl->ntl_type[i]);
+			if (mode) {
+				setbit(ic->ic_modecaps, mode);
+				setbit(&bands, mode);
+			} else
+				device_printf(dev, "Unknown nettype %d\n",
+				    ntl->ntl_type[i]);
 		}
 		free(ntl, M_DEVBUF);
 nonettypes:
+		/* Default to 11b channels if the card did not supply any */
+		if (bands == 0) {
+			setbit(ic->ic_modecaps, IEEE80211_MODE_11B);
+			setbit(&bands, IEEE80211_MODE_11B);
+		}
 		len = sizeof(rates);
 		bzero((char *)&rates, len);
 		r = ndis_get_info(sc, OID_802_11_SUPPORTED_RATES,
@@ -989,6 +1014,8 @@
 	} else
 		NDIS_UNLOCK(sc);

+	taskqueue_drain(sc->ndis_tq, &sc->ndis_scantask);
+
 	if (sc->ndis_tickitem != NULL)
 		IoFreeWorkItem(sc->ndis_tickitem);
 	if (sc->ndis_startitem != NULL)
@@ -999,6 +1026,7 @@
 		IoFreeWorkItem(sc->ndis_inputitem);

 	bus_generic_detach(dev);
+	ndis_unload_driver(sc);

 	if (sc->ndis_irq)
 		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ndis_irq);
@@ -1031,8 +1059,6 @@

 	if (sc->ndis_txpool != NULL)
 		NdisFreePacketPool(sc->ndis_txpool);
-
-	ndis_unload_driver(sc);

 	/* Destroy the PDO for this device. */

@@ -2652,36 +2678,15 @@
 	if (!NDIS_INITIALIZED(sc))
 		return;

-	/*
-	 * If we're associated, retrieve info on the current bssid.
-	 */
-	if ((rval = ndis_get_assoc(sc, &bs)) == 0) {
-		switch(bs->nwbx_nettype) {
-		case NDIS_80211_NETTYPE_11FH:
-		case NDIS_80211_NETTYPE_11DS:
-			ic->ic_curmode = IEEE80211_MODE_11B;
-			chanflag = IEEE80211_CHAN_B;
-			break;
-		case NDIS_80211_NETTYPE_11OFDM5:
-			ic->ic_curmode = IEEE80211_MODE_11A;
-			chanflag = IEEE80211_CHAN_A;
-			break;
-		case NDIS_80211_NETTYPE_11OFDM24:
-			ic->ic_curmode = IEEE80211_MODE_11G;
-			chanflag = IEEE80211_CHAN_G;
-			break;
-		default:
-			device_printf(sc->ndis_dev,
-			    "unknown nettype %d\n", arg);
-			chanflag = 0;
-			break;
-		}
-		IEEE80211_ADDR_COPY(ic->ic_bss->ni_bssid, bs->nwbx_macaddr);
-	} else
+	if ((rval = ndis_get_assoc(sc, &bs)) != 0)
 		return;

+	/* We're associated, retrieve info on the current bssid. */
+	ic->ic_curmode = ndis_nettype_mode(bs->nwbx_nettype);
+	chanflag = ndis_nettype_chan(bs->nwbx_nettype);
+	IEEE80211_ADDR_COPY(ic->ic_bss->ni_bssid, bs->nwbx_macaddr);
+
 	/* Get SSID from current association info. */
-
 	bcopy(bs->nwbx_ssid.ns_ssid, ic->ic_bss->ni_essid,
 	    bs->nwbx_ssid.ns_ssidlen);
 	ic->ic_bss->ni_esslen = bs->nwbx_ssid.ns_ssidlen;
@@ -2739,7 +2744,6 @@
 	if (ic->ic_curchan == NULL)
 		ic->ic_curchan = &ic->ic_channels[0];
 	ic->ic_bss->ni_chan = ic->ic_curchan;
-	ic->ic_des_chan = ic->ic_curchan;
 	ic->ic_bsschan = ic->ic_curchan;

 	free(bs, M_TEMP);
@@ -3502,12 +3506,42 @@
 {
 	struct ndis_softc *sc = arg;
 	struct ieee80211com *ic = (void *)&sc->ic;
+	struct ieee80211_scan_state *ss = ic->ic_scan;
+	ndis_80211_ssid ssid;
 	int error, len;
+
+	if (!NDIS_INITIALIZED(sc)) {
+		DPRINTF(("%s: scan aborted\n", __func__));
+		ieee80211_cancel_scan(ic);
+		return;
+	}
+
+	if (ss->ss_nssid != 0) {
+		/* Perform a directed scan */
+		len = sizeof(ssid);
+		bzero((char *)&ssid, len);
+		ssid.ns_ssidlen = ss->ss_ssid[0].len;
+		bcopy(ss->ss_ssid[0].ssid, ssid.ns_ssid, ssid.ns_ssidlen);
+
+		error = ndis_set_info(sc, OID_802_11_SSID, &ssid, &len);
+		if (error)
+			DPRINTF(("%s: set ESSID failed\n", __func__));
+	}

 	len = 0;
 	error = ndis_set_info(sc, OID_802_11_BSSID_LIST_SCAN,
 	    NULL, &len);
-	tsleep(&error, PPAUSE|PCATCH, "ssidscan", hz * 2);
+	if (error) {
+		DPRINTF(("%s: scan command failed\n", __func__));
+		ieee80211_cancel_scan(ic);
+		return;
+	}
+
+	tsleep(&error, PWAIT, "ssidscan", hz * 3);
+	if (!NDIS_INITIALIZED(sc))
+		/* The interface was downed while we were sleeping */
+		return;
+
 	ndis_scan_results(sc);
 	ieee80211_scan_done(ic);
 }
@@ -3521,7 +3555,7 @@
 	struct ieee80211_scanparams sp;
 	struct ieee80211_frame wh;
 	int i, j;
-	int error, len, rssi, noise;
+	int error, len, rssi, noise, freq, chanflag;
 	static long rstamp;
 	uint8_t ssid[2+IEEE80211_NWID_LEN];
 	uint8_t rates[2+IEEE80211_RATE_MAXSIZE];
@@ -3535,10 +3569,12 @@
 	bl = malloc(len, M_DEVBUF, M_NOWAIT | M_ZERO);
 	error = ndis_get_info(sc, OID_802_11_BSSID_LIST, bl, &len);
 	if (error) {
+		DPRINTF(("%s: failed to read\n", __func__));
 		free(bl, M_DEVBUF);
 		return;;
 	}

+	DPRINTF(("%s: %d results\n", __func__, bl->nblx_items));
 	rstamp++;
 	wb = &bl->nblx_bssid[0];
 	for (i = 0; i < bl->nblx_items; i++) {
@@ -3546,7 +3582,7 @@

 		memcpy(wh.i_addr2, wb->nwbx_macaddr, sizeof(wh.i_addr2));
 		memcpy(wh.i_addr3, wb->nwbx_macaddr, sizeof(wh.i_addr3));
-		rssi = (wb->nwbx_rssi - noise) / (-32 - noise) * 100;
+		rssi = 100 * (wb->nwbx_rssi - noise) / (-32 - noise);
 		rssi = max(0, min(rssi, 100));	/* limit 0 <= rssi <= 100 */
 		if (wb->nwbx_privacy)
 			sp.capinfo |= IEEE80211_CAPINFO_PRIVACY;
@@ -3573,11 +3609,10 @@
 		    wb->nwbx_ssid.ns_ssidlen);
 		sp.ssid[1] = wb->nwbx_ssid.ns_ssidlen;

-		sp.bchan = ieee80211_mhz2ieee(
-		    wb->nwbx_config.nc_dsconfig / 1000, 0);
-		sp.curchan = ieee80211_find_channel(ic,
-			ieee80211_ieee2mhz(sp.bchan, IEEE80211_CHAN_B),
-			IEEE80211_CHAN_B);
+		chanflag = ndis_nettype_chan(wb->nwbx_nettype);
+		freq = wb->nwbx_config.nc_dsconfig / 1000;
+		sp.bchan = ieee80211_mhz2ieee(freq, chanflag);
+		sp.curchan = ieee80211_find_channel(ic, freq, chanflag);
 		if (sp.curchan == NULL)
 			sp.curchan = &ic->ic_channels[0];

@@ -3607,9 +3642,13 @@
 			}
 		}
 done:
+		DPRINTF(("scan: bssid %s chan %dMHz (%d/%d) rssi %d\n",
+		    ether_sprintf(wb->nwbx_macaddr), freq, sp.bchan, chanflag,
+		    rssi));
 		ieee80211_add_scan(ic, &sp, &wh, 0, rssi, noise, rstamp);
 		wb = (ndis_wlan_bssid_ex *)((char *)wb + wb->nwbx_len);
 	}
+	free(bl, M_DEVBUF);
 }

 static void


Create after_eval_must_be_ckob.c

Create after_eval_must_be_ckob.c

C:/Users/ASUS_ux31e/Documents/RuC/RuC/tests/errors/preprocessor/after_eval_must_be_ckob.c:  #EVAL 2 + 2

 int main ()
 {
        return 0;
 }

error: pathspec 'tests/errors/preprocessor/after_eval_must_be_ckob.c' did not match any file(s) known to git

--- tests/errors/preprocessor/after_eval_must_be_ckob.c
+++ tests/errors/preprocessor/after_eval_must_be_ckob.c
@@ -0,0 +1,6 @@
+#EVAL 2 + 2
+
+int main ()
+{
+	return 0;
+}


Add USEC_SLEEP macro support. Change the location at which we define ISP_LOCK/ISP_UNLOCK macros.

--- sys/dev/isp/isp_freebsd.h
+++ sys/dev/isp/isp_freebsd.h
@@ -120,6 +120,19 @@
 };

 /*
+ * Locking macros...
+ */
+
+#ifdef	ISP_SMPLOCK
+#define	ISP_LOCK(x)		mtx_enter(&(x)->isp_osinfo.lock, MTX_DEF)
+#define	ISP_UNLOCK(x)		mtx_exit(&(x)->isp_osinfo.lock, MTX_DEF)
+#else
+#define	ISP_LOCK		isp_lock
+#define	ISP_UNLOCK		isp_unlock
+#endif
+
+
+/*
  * Required Macros/Defines
  */

@@ -133,6 +146,10 @@
 #define	SNPRINTF		snprintf
 #define	STRNCAT			strncat
 #define	USEC_DELAY		DELAY
+#define	USEC_SLEEP(isp, x)	\
+	ISP_UNLOCK(isp);	\
+	DELAY(x);		\
+	ISP_LOCK(isp)

 #define	NANOTIME_T		struct timespec
 #define	GET_NANOTIME		nanotime
@@ -273,18 +290,6 @@
  */
 extern void isp_attach(struct ispsoftc *);
 extern void isp_uninit(struct ispsoftc *);
-
-/*
- * Locking macros...
- */
-
-#ifdef	ISP_SMPLOCK
-#define	ISP_LOCK(x)		mtx_enter(&(x)->isp_osinfo.lock, MTX_DEF)
-#define	ISP_UNLOCK(x)		mtx_exit(&(x)->isp_osinfo.lock, MTX_DEF)
-#else
-#define	ISP_LOCK		isp_lock
-#define	ISP_UNLOCK		isp_unlock
-#endif

 /*
  * Platform private flags


update

update

--- c/1008/prime.c
+++ c/1008/prime.c
@@ -1,12 +1,13 @@
 #include <stdio.h>
+#include <stdlib.h>

 int isCompN(int n)
 {
-	int j, tmp;
+	int j;
 	for(j=2; j<n; j++)
 	{
-		tmp = n / j;
-		if(tmp * j == n)
+
+		if(n % j == 0)
 		{
 			return 1;
 		}
@@ -17,6 +18,7 @@
 int main()
 {
 	int i;
+  printf("Please input an Integer: ");
 	scanf("%d", &i);

 	if(i <= 1)


freebsd: ptnet_attach: allocate ethernet interface structure

--- sys/dev/netmap/if_ptnet.c
+++ sys/dev/netmap/if_ptnet.c
@@ -85,7 +85,8 @@
 #include <dev/netmap/netmap_mem2.h>

 struct ptnet_softc {
-    struct ifnet *ifp;
+	device_t dev;
+	struct ifnet *ifp;
 };

 static int	ptnet_probe(device_t);
@@ -135,11 +136,28 @@
 ptnet_attach(device_t dev)
 {
 	struct ptnet_softc *sc;
+	struct ifnet *ifp;

 	printf("%s\n", __func__);

 	sc = device_get_softc(dev);
-	sc->ifp = NULL;
+	sc->dev = dev;
+	sc->ifp = ifp = if_alloc(IFT_ETHER);
+	if (ifp == NULL) {
+		device_printf(dev, "Failed to allocate ifnet\n");
+		return (ENOMEM);
+	}
+
+	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
+	if_initbaudrate(ifp, IF_Gbps(10));
+	ifp->if_softc = sc;
+	ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST | IFF_SIMPLEX;
+	ifp->if_init = NULL;
+	ifp->if_start = NULL;
+
+	IFQ_SET_MAXLEN(&ifp->if_snd, 255);
+	ifp->if_snd.ifq_drv_maxlen = 255;
+	IFQ_SET_READY(&ifp->if_snd);

 	return (0);
 }


parse the ZMQ responses from the key oracle

--- c/gatekeeper.c
+++ c/gatekeeper.c
@@ -63,6 +63,7 @@
 int uid_valid(char* uid, uint32_t *acl)
 {
     int err;
+    int card_ret = -1;
     void *context = zmq_init(ZMQ_NUM_IOTHREADS);
     void *requester = zmq_socket(context, ZMQ_REQ);
     err = zmq_connect(requester, ZMQ_DB_ORACLE_ADDRESS);
@@ -112,10 +113,48 @@

         // Read the body as string
         char* body = msg_to_str(&message);
-        printf("==\n%s\n==\n", body);
+
+        switch(partno)
+        {
+            case 1:
+                if (strcmp(body, "OK") == 0)
+                {
+                    card_ret = 0;
+                    break;
+                }
+                if (strcmp(body, "NF") == 0)
+                {
+                    card_ret = -2;
+                    break;
+                }
+                if (strcmp(body, "REV") == 0)
+                {
+                    card_ret = -3;
+                    break;
+                }
+                printf("Don't know what part %d body '%s' means\n", partno, body);
+                break;
+            case 2:
+                switch(card_ret)
+                {
+                    case 0:
+                        // Parse the ACL (hex-encoded) number
+                        *acl = strtol(body, NULL, 0);
+                        break;
+                    case -2:
+                        // fall-through
+                    case -3:
+                        *acl = 0x0;
+                        break;
+                }
+                break;
+            default:
+                printf("Received message part %d, don't know what to do with it", partno);
+                break;
+        }
+
+        // Done with message
         free(body);
-
-        // Done with message
         zmq_msg_close (&message);

         // See if we have more parts
@@ -133,10 +172,7 @@
         }
     }
     printf("All %d parts received\n", partno);
-    err = 0;
-    // FIXME: Parse this from the ZMQ message
-    *acl = 0x1;
-
+    err = card_ret;
 END:
     zmq_close(requester);
     zmq_term(context);
@@ -261,6 +297,7 @@
                 goto FAIL;
         }
     }
+    printf("db_acl=0x%lx \n", (unsigned long)db_acl);

     printf("Re-auth with ACL read key, ");
     key = mifare_desfire_aes_key_new_with_version((uint8_t*)diversified_key_data, 0x0);


Fix the sound driver vchan support to work when hw.snd.maxautovchans
has been specified through /boot/loader.conf as opposed to setting it
in /etc/sysctl.conf. Only PCMDIR_PLAY channel can be used as a parent
of virtual channel. Do not initialize a new vchan for a given physical
channel if other physical channel already has one created.

PR:	31597
Approved by:	obrien (mentor)

--- sys/dev/sound/pcm/sound.c
+++ sys/dev/sound/pcm/sound.c
@@ -504,7 +504,8 @@
 		return err;
 	}

-	if (snd_maxautovchans > 0 && (d->flags & SD_F_AUTOVCHAN)) {
+	if (snd_maxautovchans > 0 && (d->flags & SD_F_AUTOVCHAN) &&
+	    ch->direction == PCMDIR_PLAY && d->vchancount == 0) {
 		ch->flags |= CHN_F_BUSY;
 		err = vchan_create(ch);
 		if (err) {


Bug fix: Decrease reference count of array object obtained by PyArray_FROMANY before exiting.

--- c/neighbours.c
+++ c/neighbours.c
@@ -147,6 +147,8 @@
             cutoff = max(cutoff, cutoffs[i]);
             cutoffs_sq[i] = cutoffs[i]*cutoffs[i];
         }
+
+        Py_DECREF(py_cutoffs);
     }

     /* FIXME! Check array shapes. */
@@ -481,7 +483,7 @@
             }
         }
     }
-
+
     /* Release cell subdivision information */
     free(seed);
     free(next);
@@ -531,10 +533,24 @@
         Py_INCREF(py_ret);
         Py_DECREF(py_tuple);
     }
+
+    /* Final cleanup */
+    Py_DECREF(py_cell);
+    Py_DECREF(py_inv_cell);
+    Py_DECREF(py_pbc);
+    Py_DECREF(py_r);
+    if (py_types)  Py_DECREF(py_types);
+
     return py_ret;

     fail:
     /* Cleanup. Sorry for the goto. */
+    Py_DECREF(py_cell);
+    Py_DECREF(py_inv_cell);
+    Py_DECREF(py_pbc);
+    Py_DECREF(py_r);
+    if (py_types)  Py_DECREF(py_types);
+
     if (seed)  free(seed);
     if (next)  free(next);
     if (cutoffs_sq)  free(cutoffs_sq);


Style: move opt_*.h includes in the proper place.

MFC after:	1 month

--- sys/kern/sys_capability.c
+++ sys/kern/sys_capability.c
@@ -51,11 +51,11 @@
  * anonymous, rather than named, POSIX shared memory objects.
  */

+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
 #include "opt_capsicum.h"
 #include "opt_ktrace.h"
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");

 #include <sys/param.h>
 #include <sys/capability.h>


Fixup init

Fixup init

--- c_src/crypto.c
+++ c_src/crypto.c
@@ -87,7 +87,7 @@
     erlrt_evp_md_ctx = enif_open_resource_type(
             env, "crypto2",
             "erlrt_evp_md_ctx",
-            (ErlNifResourceDtor)evp_md_destructor,
+            (ErlNifResourceDtor*)evp_md_destructor,
             ERL_NIF_RT_CREATE,
             NULL);


- Add iso88025_ifdetach(). - Add support for 802.2 type IPX frames. - Cleanup iso88025_output() and iso88025_output() a bit.

--- sys/net/if_iso88025subr.c
+++ sys/net/if_iso88025subr.c
@@ -41,6 +41,8 @@
  */

 #include "opt_inet.h"
+#include "opt_inet6.h"
+#include "opt_ipx.h"

 #include <sys/param.h>
 #include <sys/systm.h>
@@ -60,11 +62,19 @@

 #include <net/iso88025.h>

-#ifdef INET
+#if defined(INET) || defined(INET6)
 #include <netinet/in.h>
 #include <netinet/in_var.h>
 #include <netinet/if_ether.h>
 #endif
+#ifdef INET6
+#include <netinet6/nd6.h>
+#endif
+
+#ifdef IPX
+#include <netipx/ipx.h>
+#include <netipx/ipx_if.h>
+#endif

 #include <net/bpf.h>

@@ -75,6 +85,8 @@
 #include <vm/pmap.h>

 #include <net/iso88025.h>
+
+#define IFP2AC(IFP) ((struct arpcom *)IFP)

 void
 iso88025_ifattach(struct ifnet *ifp)
@@ -101,6 +113,20 @@
         bcopy(((struct arpcom *)ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen);
 }

+/*
+ * Perform common duties while detaching a Token Ring interface
+ */
+void
+iso88025_ifdetach(ifp, bpf)
+        struct ifnet *ifp;
+        int bpf;
+{
+	if (bpf)
+                bpfdetach(ifp);
+	if_detach(ifp);
+}
+
+
 int
 iso88025_ioctl(struct ifnet *ifp, int command, caddr_t data)
 {
@@ -118,7 +144,33 @@
                         ifp->if_init(ifp->if_softc);    /* before arpwhohas */
                         arp_ifinit((struct arpcom *)ifp, ifa);
                         break;
-#endif
+#endif	/* INET */
+#ifdef IPX
+                /*
+                 * XXX - This code is probably wrong
+                 */
+                case AF_IPX:
+                        {
+                        register struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr);
+                        struct arpcom *ac = IFP2AC(ifp);
+
+                        if (ipx_nullhost(*ina))
+                                ina->x_host =
+                                    *(union ipx_host *)
+                                    ac->ac_enaddr;
+                        else {
+                                bcopy((caddr_t) ina->x_host.c_host,
+                                      (caddr_t) ac->ac_enaddr,
+                                      sizeof(ac->ac_enaddr));
+                        }
+
+                        /*
+                         * Set new address
+                         */
+                        ifp->if_init(ifp->if_softc);
+                        break;
+                        }
+#endif	/* IPX */
                 default:
                         ifp->if_init(ifp->if_softc);
                         break;
@@ -153,23 +205,27 @@
  * ISO88025 encapsulation
  */
 int
-iso88025_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct rtentry *rt0)
+iso88025_output(ifp, m, dst, rt0)
+	struct ifnet *ifp;
+	struct mbuf *m;
+	struct sockaddr *dst;
+	struct rtentry *rt0;
 {
-	register struct iso88025_header *th;
+	u_int16_t snap_type = 0;
+        int loop_copy = 0, error = 0, rif_len = 0;
+ 	u_char edst[ISO88025_ADDR_LEN];
+	struct iso88025_header *th;
 	struct iso88025_header gen_th;
-	register struct iso88025_sockaddr_data *sd = (struct iso88025_sockaddr_data *)dst->sa_data;
-        register struct llc *l;
-	register struct sockaddr_dl *sdl = NULL;
-        int error = 0, rif_len = 0;
- 	u_char edst[6];
-	register struct rtentry *rt;
-	int loop_copy = 0;
+	struct sockaddr_dl *sdl = NULL;
+	struct rtentry *rt;
 	struct arpcom *ac = (struct arpcom *)ifp;

 	if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
 		senderr(ENETDOWN);
+	getmicrotime(&ifp->if_lastchange);
+
 	rt = rt0;
-	if (rt) {
+	if (rt != NULL) {
 		if ((rt->rt_flags & RTF_UP) == 0) {
 			rt0 = rt = rtalloc1(dst, 1, 0UL);
 			if (rt0)
@@ -202,37 +258,61 @@
 	/* Generate a generic 802.5 header for the packet */
 	gen_th.ac = TR_AC;
 	gen_th.fc = TR_LLC_FRAME;
-	memcpy(gen_th.iso88025_shost, ac->ac_enaddr, sizeof(ac->ac_enaddr));
+	(void)memcpy((caddr_t)gen_th.iso88025_shost, (caddr_t)ac->ac_enaddr,
+		sizeof(ac->ac_enaddr));
 	if (rif_len) {
 		gen_th.iso88025_shost[0] |= TR_RII;
 		if (rif_len > 2) {
 			gen_th.rcf = sdl->sdl_rcf;
-			memcpy(gen_th.rd, sdl->sdl_route, rif_len - 2);
+			(void)memcpy((caddr_t)gen_th.rd,
+				(caddr_t)sdl->sdl_route, rif_len - 2);
 		}
 	}

-
 	switch (dst->sa_family) {
 #ifdef INET
 	case AF_INET:
 		if (!arpresolve(ac, rt, m, dst, edst, rt0))
 			return (0);	/* if not yet resolved */
-		/* Add LLC and SNAP headers */
-		M_PREPEND(m, 8, M_DONTWAIT);
+		snap_type = ETHERTYPE_IP;
+		break;
+#endif	/* INET */
+#ifdef NOT_YET
+#ifdef INET6
+	case AF_INET6:
+		if (!nd6_storelladdr(&ac->ac_if, rt, m, dst, (u_char *)edst)) {
+			/* Something bad happened */
+			return(0);
+		}
+		snap_type = ETHERTYPE_IPV6;
+		break;
+#endif	/* INET6 */
+#endif	/* NOT_YET */
+#ifdef IPX
+	case AF_IPX:
+	{
+		u_int8_t	*cp;
+
+		snap_type = 0;
+		bcopy((caddr_t)&(satoipx_addr(dst).x_host), (caddr_t)edst,
+			sizeof (edst));
+
+		M_PREPEND(m, 3, M_TRYWAIT);
 		if (m == 0)
 			senderr(ENOBUFS);
-		l = mtod(m, struct llc *);
-	        l->llc_un.type_snap.ether_type = htons(ETHERTYPE_IP);
-	        l->llc_dsap = l->llc_ssap = LLC_SNAP_LSAP;
-		l->llc_un.type_snap.control = LLC_UI;
-		l->llc_un.type_snap.org_code[0] = 0x0;
-		l->llc_un.type_snap.org_code[1] = 0x0;
-		l->llc_un.type_snap.org_code[2] = 0x0;
-		memcpy(gen_th.iso88025_dhost, edst, sizeof(edst));
-		break;
-#endif
-
+		m = m_pullup(m, 3);
+		if (m == 0)
+			senderr(ENOBUFS);
+		cp = mtod(m, u_int8_t *);
+		*cp++ = ETHERTYPE_IPX_8022;
+		*cp++ = ETHERTYPE_IPX_8022;
+		*cp++ = LLC_UI;
+	}
+	break;
+#endif	/* IPX */
 	case AF_UNSPEC:
+	{
+		struct iso88025_sockaddr_data *sd;
 		/*
 		 * For AF_UNSPEC sockaddr.sa_data must contain all of the
 		 * mac information needed to send the packet.  This allows
@@ -245,25 +325,44 @@
 		sd = (struct iso88025_sockaddr_data *)dst->sa_data;
 		gen_th.ac = sd->ac;
 		gen_th.fc = sd->fc;
-		memcpy(gen_th.iso88025_dhost, sd->ether_dhost, sizeof(sd->ether_dhost));
-		memcpy(gen_th.iso88025_shost, sd->ether_shost, sizeof(sd->ether_shost));
+		(void)memcpy((caddr_t)edst, (caddr_t)sd->ether_dhost,
+			sizeof(sd->ether_dhost));
+		(void)memcpy((caddr_t)gen_th.iso88025_shost,
+			(caddr_t)sd->ether_shost, sizeof(sd->ether_shost));
 		rif_len = 0;
 		break;
-
+	}
 	default:
 		printf("%s%d: can't handle af%d\n", ifp->if_name, ifp->if_unit,
 			dst->sa_family);
 		senderr(EAFNOSUPPORT);
+		break;
+	}
+
+	if (snap_type != 0) {
+        	struct llc *l;
+		M_PREPEND(m, sizeof (struct llc), M_DONTWAIT);
+		if (m == 0)
+			senderr(ENOBUFS);
+		l = mtod(m, struct llc *);
+		l->llc_un.type_snap.ether_type = htons(snap_type);
+		l->llc_dsap = l->llc_ssap = LLC_SNAP_LSAP;
+		l->llc_un.type_snap.control = LLC_UI;
+		l->llc_un.type_snap.org_code[0] =
+			l->llc_un.type_snap.org_code[1] =
+			l->llc_un.type_snap.org_code[2] = 0;
 	}

 	/*
 	 * Add local net header.  If no space in first mbuf,
 	 * allocate another.
 	 */
-
 	M_PREPEND(m, ISO88025_HDR_LEN + rif_len, M_DONTWAIT);
 	if (m == 0)
 		senderr(ENOBUFS);
+
+	(void)memcpy((caddr_t)&gen_th.iso88025_dhost, (caddr_t)edst,
+		     sizeof(edst));

 	/* Copy as much of the generic header as is needed into the mbuf */
 	th = mtod(m, struct iso88025_header *);
@@ -278,21 +377,22 @@
          * on the wire). However, we don't do that here for security
          * reasons and compatibility with the original behavior.
          */
-        if ((ifp->if_flags & IFF_SIMPLEX) &&
-           (loop_copy != -1)) {
+        if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) {
                 if ((m->m_flags & M_BCAST) || (loop_copy > 0)) {
-                        struct mbuf *n = m_copy(m, 0, (int)M_COPYALL);
-                        (void) if_simloop(ifp,
-			    n, dst->sa_family, ISO88025_HDR_LEN);
-                } else if (bcmp(th->iso88025_dhost,
-                    th->iso88025_shost, ETHER_ADDR_LEN) == 0) {
-                        (void) if_simloop(ifp,
-			    m, dst->sa_family, ISO88025_HDR_LEN);
-                        return(0);      /* XXX */
-                }
+                        struct mbuf *n;
+			n = m_copy(m, 0, (int)M_COPYALL);
+                        (void)if_simloop(ifp, n, dst->sa_family,
+					  ISO88025_HDR_LEN);
+                } else
+			if (bcmp(th->iso88025_dhost, th->iso88025_shost,
+				 ETHER_ADDR_LEN) == 0) {
+				(void)if_simloop(ifp, m, dst->sa_family,
+						 ISO88025_HDR_LEN);
+                        	return(0);      /* XXX */
+			}
         }

-	if (! IF_HANDOFF_ADJ(&ifp->if_snd, m, ifp, ISO88025_HDR_LEN + 8)) {
+	if (! IF_HANDOFF_ADJ(&ifp->if_snd, m, ifp, ISO88025_HDR_LEN + (sizeof(struct llc))) ) {
 		printf("iso88025_output: packet dropped QFULL.\n");
 		senderr(ENOBUFS);
 	}
@@ -308,92 +408,158 @@
  * ISO 88025 de-encapsulation
  */
 void
-iso88025_input(struct ifnet *ifp, struct iso88025_header *th, struct mbuf *m)
+iso88025_input(ifp, th, m)
+	struct ifnet *ifp;
+	struct iso88025_header *th;
+	struct mbuf *m;
 {
 	register struct ifqueue *inq;
-	u_short ether_type;
-	register struct llc *l = mtod(m, struct llc *);
+	register struct llc *l;

 	if ((ifp->if_flags & IFF_UP) == 0) {
 		m_freem(m);
 		return;
 	}

-	switch (l->llc_control) {
-	case LLC_UI:
-		break;
-	case LLC_TEST:
-	case LLC_TEST_P:
-	{
-		struct sockaddr sa;
-		struct arpcom *ac = (struct arpcom *)ifp;
-		struct iso88025_sockaddr_data *th2;
-		int i;
-		u_char c = l->llc_dsap;
-
-		if (th->iso88025_shost[0] & TR_RII) { /* XXX */
-			printf("iso88025_input: dropping source routed LLC_TEST\n");
-			m_free(m);
-			return;
-		}
-		l->llc_dsap = l->llc_ssap;
-		l->llc_ssap = c;
-		if (m->m_flags & (M_BCAST | M_MCAST))
-			bcopy((caddr_t)ac->ac_enaddr,
-			      (caddr_t)th->iso88025_dhost, ISO88025_ADDR_LEN);
-		sa.sa_family = AF_UNSPEC;
-		sa.sa_len = sizeof(sa);
-		th2 = (struct iso88025_sockaddr_data *)sa.sa_data;
-		for (i = 0; i < ISO88025_ADDR_LEN; i++) {
-			th2->ether_shost[i] = c = th->iso88025_dhost[i];
-			th2->ether_dhost[i] = th->iso88025_dhost[i] = th->iso88025_shost[i];
-			th->iso88025_shost[i] = c;
-		}
-		th2->ac = TR_AC;
-		th2->fc = TR_LLC_FRAME;
-		ifp->if_output(ifp, m, &sa, NULL);
-		return;
-	}
-	default:
-		printf("iso88025_input: unexpected llc control 0x%02x\n", l->llc_control);
-		m_freem(m);
-		return;
-	}
-
-        m->m_pkthdr.len -= 8;
-        m->m_len -= 8;
-        m->m_data += 8; /* Length of LLC header in our case */
-
+	getmicrotime(&ifp->if_lastchange);
 	ifp->if_ibytes += m->m_pkthdr.len + sizeof(*th);
+
 	if (th->iso88025_dhost[0] & 1) {
-		if (bcmp((caddr_t)etherbroadcastaddr, (caddr_t)th->iso88025_dhost, sizeof(etherbroadcastaddr)) == 0)
+		if (bcmp((caddr_t)etherbroadcastaddr,
+			 (caddr_t)th->iso88025_dhost,
+			 sizeof(etherbroadcastaddr)) == 0)
 			m->m_flags |= M_BCAST;
 		else
 			m->m_flags |= M_MCAST;
+		ifp->if_imcasts++;
 	}
-	if (m->m_flags & (M_BCAST|M_MCAST))
-		ifp->if_imcasts++;
-
-	ether_type = ntohs(l->llc_un.type_snap.ether_type);
-
-	switch (ether_type) {
+
+	l = mtod(m, struct llc *);
+
+	switch (l->llc_dsap) {
+#ifdef IPX
+	case ETHERTYPE_IPX_8022:	/* Thanks a bunch Novell */
+		if ((l->llc_control != LLC_UI) ||
+		    (l->llc_ssap != ETHERTYPE_IPX_8022))
+			goto dropanyway;
+
+		th->iso88025_shost[0] &= ~(TR_RII);
+		m_adj(m, 3);
+		schednetisr(NETISR_IPX);
+		inq = &ipxintrq;
+		break;
+#endif	/* IPX */
+	case LLC_SNAP_LSAP: {
+		u_int16_t type;
+		if ((l->llc_control != LLC_UI) ||
+		    (l->llc_ssap != LLC_SNAP_LSAP))
+			goto dropanyway;
+
+		if (l->llc_un.type_snap.org_code[0] != 0 ||
+		    l->llc_un.type_snap.org_code[1] != 0 ||
+		    l->llc_un.type_snap.org_code[2] != 0)
+			goto dropanyway;
+
+		type = ntohs(l->llc_un.type_snap.ether_type);
+		m_adj(m, sizeof(struct llc));
+		switch (type) {
 #ifdef INET
-	case ETHERTYPE_IP:
-		th->iso88025_shost[0] &= ~(TR_RII);
-		if (ipflow_fastforward(m))
+		case ETHERTYPE_IP:
+			th->iso88025_shost[0] &= ~(TR_RII);
+			if (ipflow_fastforward(m))
+				return;
+			schednetisr(NETISR_IP);
+			inq = &ipintrq;
+			break;
+
+		case ETHERTYPE_ARP:
+			schednetisr(NETISR_ARP);
+			inq = &arpintrq;
+			break;
+#endif	/* INET */
+#ifdef IPX_SNAP	/* XXX: Not supported! */
+		case ETHERTYPE_IPX:
+			th->iso88025_shost[0] &= ~(TR_RII);
+			schednetisr(NETISR_IPX);
+			inq = &ipxintrq;
+			break;
+#endif	/* IPX_SNAP */
+#ifdef NOT_YET
+#ifdef INET6
+		case ETHERTYPE_IPV6:
+			th->iso88025_shost[0] &= ~(TR_RII);
+			schednetisr(NETISR_IPV6);
+			inq = &ip6intrq;
+			break;
+#endif	/* INET6 */
+#endif	/* NOT_YET */
+		default:
+			printf("iso88025_input: unexpected llc_snap ether_type  0x%02x\n", type);
+			m_freem(m);
 			return;
-		schednetisr(NETISR_IP);
-		inq = &ipintrq;
-		break;
-
-	case ETHERTYPE_ARP:
-		schednetisr(NETISR_ARP);
-		inq = &arpintrq;
-                break;
-#endif
+		}
+		break;
+	}
+	case LLC_ISO_LSAP:
+		switch (l->llc_control) {
+		case LLC_UI:
+			goto dropanyway;
+			break;
+                case LLC_XID:
+                case LLC_XID_P:
+			if(m->m_len < ISO88025_ADDR_LEN)
+				goto dropanyway;
+			l->llc_window = 0;
+			l->llc_fid = 9;
+			l->llc_class = 1;
+			l->llc_dsap = l->llc_ssap = 0;
+			/* Fall through to */
+		case LLC_TEST:
+		case LLC_TEST_P:
+		{
+			struct sockaddr sa;
+			struct arpcom *ac = (struct arpcom *)ifp;
+			struct iso88025_sockaddr_data *th2;
+			int i;
+			u_char c = l->llc_dsap;
+
+			if (th->iso88025_shost[0] & TR_RII) { /* XXX */
+				printf("iso88025_input: dropping source routed LLC_TEST\n");
+				m_free(m);
+				return;
+			}
+			l->llc_dsap = l->llc_ssap;
+			l->llc_ssap = c;
+			if (m->m_flags & (M_BCAST | M_MCAST))
+				bcopy((caddr_t)ac->ac_enaddr,
+			      		(caddr_t)th->iso88025_dhost,
+					ISO88025_ADDR_LEN);
+			sa.sa_family = AF_UNSPEC;
+			sa.sa_len = sizeof(sa);
+			th2 = (struct iso88025_sockaddr_data *)sa.sa_data;
+			for (i = 0; i < ISO88025_ADDR_LEN; i++) {
+				th2->ether_shost[i] = c = th->iso88025_dhost[i];
+				th2->ether_dhost[i] = th->iso88025_dhost[i] =
+					th->iso88025_shost[i];
+				th->iso88025_shost[i] = c;
+			}
+			th2->ac = TR_AC;
+			th2->fc = TR_LLC_FRAME;
+			ifp->if_output(ifp, m, &sa, NULL);
+			return;
+		}
+		default:
+			printf("iso88025_input: unexpected llc control 0x%02x\n", l->llc_control);
+			m_freem(m);
+			return;
+		}
+		break;
 	default:
-	    m_freem(m);
-	    return;
+		printf("iso88025_input: unknown dsap 0x%x\n", l->llc_dsap);
+		ifp->if_noproto++;
+	dropanyway:
+		m_freem(m);
+		return;
 	}

 	if (! IF_HANDOFF(inq, m, NULL))


If not set (due to some error Michael is working on
fixing) set it for the net.

MFC after:	3 months

--- sys/netinet/sctp_output.c
+++ sys/netinet/sctp_output.c
@@ -3485,6 +3485,12 @@
 		SCTP_BUF_NEXT(newm) = m;
 		m = newm;
 		if (net != NULL) {
+			if (net->flowidset == 0) {
+				net->flowid = stcb->asoc.my_vtag ^
+				    ntohs(stcb->rport) ^
+				    ntohs(stcb->sctp_ep->sctp_lport);
+				net->flowidset = 1;
+			}
 			m->m_pkthdr.flowid = net->flowid;
 			m->m_flags |= M_FLOWID;
 		} else {
@@ -3815,6 +3821,12 @@
 		SCTP_BUF_NEXT(newm) = m;
 		m = newm;
 		if (net != NULL) {
+			if (net->flowidset == 0) {
+				net->flowid = stcb->asoc.my_vtag ^
+				    ntohs(stcb->rport) ^
+				    ntohs(stcb->sctp_ep->sctp_lport);
+				net->flowidset = 1;
+			}
 			m->m_pkthdr.flowid = net->flowid;
 			m->m_flags |= M_FLOWID;
 		} else {


ebb: Add all the EBB register for the m[tf]spr

--- ebb/ebb-common.h
+++ ebb/ebb-common.h
@@ -30,7 +30,10 @@
 #define _PAF_EBB_COMMON_H

 /* Constants used to get/set the EBB register through m[t|f]spr.  */
-#define MMCR0	    779  /* Monitor Mode Control Register 0.  */
+#define MMCR0       779  /* Monitor Mode Control Register 0.  */
+#define MMCRA       770
+#define MMCR1       782
+#define MMCR2       769
 #define MMCR0_FC    0x80000000
 #define MMCR0_PMAO  0x00000080
 #define MMCR0_PMAE  0x04000000


Don't clear the attribute cache of a file when it is closed.  A subsequent
open() of the same file will load fresh attributes, so they do not need to
be explicitly flushed in close() to guarantee close to open consistency.
However, other file desciptors may still reference this file and clearing
the attributes in close() forces those other file descriptors to fetch
fresh attributes the next time they need them.

Reviewed by:	mohans
MFC after:	1 week


Fix dmake's behavior when the environment is broken.

You can have environment with spaces in the name of the environment variable.
Even though this is broken, it does not cause trouble to most of the tools
around, so we should work that around in dmake too ;-)

dmake-space-in-envvar-name.diff, i#101786

--- dmake/getinp.c
+++ dmake/getinp.c
@@ -88,17 +88,23 @@
       /* Reading the internal rule table.  Set rule_ind to zero after the
        * last entry so that ReadEnvironment() works as expected every time. */

-      while( (p = Rule_tab[ rule_ind++ ]) != NIL(char) )
+      while( (p = Rule_tab[ rule_ind++ ]) != NIL(char) ) {
      /* The last test in this if *p != '~', handles the environment
       * passing conventions used by MKS to pass arguments.  We want to
       * skip those environment entries. Also CYGWIN likes to export '!'
-      * prefixed environment variables that cause severe pain, axe them too */
-     if( !Readenv || (Readenv && (strchr(p,'=') != NIL(char)) && *p!='~' && *p!='!')){
+      * prefixed environment variables that cause severe pain, axe them too.
+      * And finally it is possible to do "env 'GGG HHH'='some value' bash"
+      * which causes that there are env variables with spaces in the name
+      * defined which causes dmake to malfunction too */
+     char *equal = strchr(p,'=');
+     char *space = strchr(p,' ');
+     if( !Readenv || (Readenv && (equal != NIL(char)) && (space == NIL(char) || space > equal) && *p!='~' && *p!='!')){
         strcpy( buf, p );

         DB_PRINT( "io", ("Returning [%s]", buf) );
         DB_RETURN( FALSE );
      }
+      }

       rule_ind = 0;


MFp4: SMP support

MFp4: SMP support

--- sys/powerpc/include/smp.h
+++ sys/powerpc/include/smp.h
@@ -1,7 +1,64 @@
-/* $FreeBSD$ */
+/*-
+ * Copyright (c) 2008 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */

-/*
- * An empty file now,
- * Although in the times to come,
- * More may be found here.
- */
+#ifndef _MACHINE_SMP_H_
+#define _MACHINE_SMP_H_
+
+#ifdef _KERNEL
+
+#define	IPI_AST			0
+#define	IPI_PREEMPT		1
+#define	IPI_RENDEZVOUS		2
+#define	IPI_STOP		3
+
+#define	IPI_PPC_TEST		4
+
+#ifndef LOCORE
+
+void	ipi_all(int ipi);
+void	ipi_all_but_self(int ipi);
+void	ipi_selected(cpumask_t cpus, int ipi);
+void	ipi_self(int ipi);
+
+struct cpuref {
+	uintptr_t	cr_hwref;
+	u_int		cr_cpuid;
+};
+
+int	powerpc_smp_first_cpu(struct cpuref *);
+int	powerpc_smp_get_bsp(struct cpuref *);
+int	powerpc_smp_next_cpu(struct cpuref *);
+int	powerpc_smp_start_cpu(struct pcpu *);
+
+void	pmap_cpu_bootstrap(volatile uint32_t *, int);
+uint32_t cpudep_ap_bootstrap(volatile uint32_t *);
+void	machdep_ap_bootstrap(volatile uint32_t *);
+
+#endif /* !LOCORE */
+#endif /* _KERNEL */
+#endif /* !_MACHINE_SMP_H */


Add IRQ support to the resource list handling functions.


sys/riotboot/flashwrite: when invalidating erase checksum as well

--- sys/riotboot/flashwrite.c
+++ sys/riotboot/flashwrite.c
@@ -29,11 +29,6 @@

 #define LOG_PREFIX "riotboot_flashwrite: "
 #include "log.h"
-
-/**
- * @brief Magic number used to invalidate a slot
- */
-#define INVALIDATE_HDR                  0xAA

 static inline size_t min(size_t a, size_t b)
 {
@@ -178,10 +173,14 @@
         return -2;
     }

-    uint8_t data_flash[4];
-    memset(data_flash, INVALIDATE_HDR, sizeof(data_flash));
-
-    flashpage_write((void *)riotboot_slot_get_hdr(slot), data_flash, sizeof(data_flash));
+    /* invalidate header (checksum and magic number must be invalidated),
+       write the whole header to avoid running in memory alignment issues
+       with FLASHPAGE_WRITE_BLOCK_SIZE */
+    riotboot_hdr_t tmp_hdr;
+    memset(&tmp_hdr, (~FLASHPAGE_ERASE_STATE), sizeof(riotboot_hdr_t));
+
+    flashpage_write((void *)riotboot_slot_get_hdr(slot), &tmp_hdr,
+                    sizeof(riotboot_hdr_t));

     return 0;
 }


JNEWBLK dependency may legitimately appear on the buf dependency
list. If softdep_sync_buf() discovers such dependency, it should do
nothing, which is safe as it is only waiting on the parent buffer to
be written, so it can be removed.

Committed on behalf of:	 jeff
MFC after:   1 week


More aggressively rate limit the growth of soft dependency structures
in the face of multiple processes doing massive numbers of filesystem
operations. While this patch will work in nearly all situations, there
are still some perverse workloads that can overwhelm the system.
Detecting and handling these perverse workloads will be the subject
of another patch.

Reviewed by:	Paul Saab <ps@yahoo-inc.com>
Obtained from:	Ethan Solomita <ethan@geocast.com>

--- sys/ufs/ffs/ffs_softdep.c
+++ sys/ufs/ffs/ffs_softdep.c
@@ -440,6 +440,8 @@
 static int max_softdeps;	/* maximum number of structs before slowdown */
 static int tickdelay = 2;	/* number of ticks to pause during slowdown */
 static int proc_waiting;	/* tracks whether we have a timeout posted */
+static int *stat_countp;	/* statistic to count in proc_waiting timeout */
+static struct callout_handle handle; /* handle on posted proc_waiting timeout */
 static struct proc *filesys_syncer; /* proc of filesystem syncer process */
 static int req_clear_inodedeps;	/* syncer process flush some inodedeps */
 #define FLUSH_INODES	1
@@ -531,13 +533,13 @@
 	 */
 	if (req_clear_inodedeps) {
 		clear_inodedeps(p);
-		req_clear_inodedeps = 0;
-		wakeup(&proc_waiting);
+		req_clear_inodedeps -= 1;
+		wakeup_one(&proc_waiting);
 	}
 	if (req_clear_remove) {
 		clear_remove(p);
-		req_clear_remove = 0;
-		wakeup(&proc_waiting);
+		req_clear_remove -= 1;
+		wakeup_one(&proc_waiting);
 	}
 	ACQUIRE_LOCK(&lk);
 	loopcount = 1;
@@ -602,13 +604,13 @@
 		 */
 		if (req_clear_inodedeps) {
 			clear_inodedeps(p);
-			req_clear_inodedeps = 0;
-			wakeup(&proc_waiting);
+			req_clear_inodedeps -= 1;
+			wakeup_one(&proc_waiting);
 		}
 		if (req_clear_remove) {
 			clear_remove(p);
-			req_clear_remove = 0;
-			wakeup(&proc_waiting);
+			req_clear_remove -= 1;
+			wakeup_one(&proc_waiting);
 		}
 		/*
 		 * We do not generally want to stop for buffer space, but if
@@ -1683,7 +1685,6 @@
 	 * been written to disk, so we can free any fragments without delay.
 	 */
 	merge_inode_lists(inodedep);
-	delay = (inodedep->id_state & DEPCOMPLETE);
 	while ((adp = TAILQ_FIRST(&inodedep->id_inoupdt)) != 0)
 		free_allocdirect(&inodedep->id_inoupdt, adp, delay);
 	FREE_LOCK(&lk);
@@ -4347,7 +4348,6 @@
 	int resource;
 	int islocked;
 {
-	struct callout_handle handle;
 	struct proc *p = CURPROC;

 	/*
@@ -4369,12 +4369,14 @@

 	case FLUSH_INODES:
 		stat_ino_limit_push += 1;
-		req_clear_inodedeps = 1;
+		req_clear_inodedeps += 1;
+		stat_countp = &stat_ino_limit_hit;
 		break;

 	case FLUSH_REMOVE:
 		stat_blk_limit_push += 1;
-		req_clear_remove = 1;
+		req_clear_remove += 1;
+		stat_countp = &stat_blk_limit_hit;
 		break;

 	default:
@@ -4386,29 +4388,14 @@
 	 */
 	if (islocked == 0)
 		ACQUIRE_LOCK(&lk);
-	if (proc_waiting == 0) {
-		proc_waiting = 1;
-		handle = timeout(pause_timer, NULL,
-		    tickdelay > 2 ? tickdelay : 2);
+	if (proc_waiting++ == 0) {
+		handle = timeout(pause_timer, 0, tickdelay > 2 ? tickdelay : 2);
 	}
 	FREE_LOCK_INTERLOCKED(&lk);
 	(void) tsleep((caddr_t)&proc_waiting, PPAUSE, "softupdate", 0);
 	ACQUIRE_LOCK_INTERLOCKED(&lk);
-	if (proc_waiting) {
-		untimeout(pause_timer, NULL, handle);
-		proc_waiting = 0;
-	} else {
-		switch (resource) {
-
-		case FLUSH_INODES:
-			stat_ino_limit_hit += 1;
-			break;
-
-		case FLUSH_REMOVE:
-			stat_blk_limit_hit += 1;
-			break;
-		}
-	}
+	if (--proc_waiting == 0)
+		untimeout(pause_timer, 0, handle);
 	if (islocked == 0)
 		FREE_LOCK(&lk);
 	return (1);
@@ -4423,8 +4410,9 @@
 	void *arg;
 {

-	proc_waiting = 0;
-	wakeup(&proc_waiting);
+	*stat_countp += 1;
+	handle = timeout(pause_timer, 0, tickdelay > 2 ? tickdelay : 2);
+	wakeup_one(&proc_waiting);
 }

 /*


Revert "[Core] Fix event loop instrumentation causing Java segfaults in tests. (#15349)" (#15727)

This reverts commit edb0d1b3766a79d2460a1de135854c4c219cb3a5.

--- src/ray/common/ray_config_def.h
+++ src/ray/common/ray_config_def.h
@@ -50,7 +50,7 @@
 /// The duration between dumping debug info to logs, or 0 to disable.
 RAY_CONFIG(uint64_t, debug_dump_period_milliseconds, 10000)

-RAY_CONFIG(bool, asio_event_loop_stats_collection_enabled, true)
+RAY_CONFIG(bool, asio_event_loop_stats_collection_enabled, false)

 /// Whether to enable fair queueing between task classes in raylet. When
 /// fair queueing is enabled, the raylet will try to balance the number


Only save dirty children.

Only save dirty children.

--- gom/gom-collection.c
+++ gom/gom-collection.c
@@ -89,8 +89,10 @@
 	if (priv->to_add) {
 		for (i = 0; i < priv->to_add->len; i++) {
 			resource = g_ptr_array_index(priv->to_add, i);
-			if (!gom_resource_save(resource, error)) {
-				return FALSE;
+			if (gom_resource_is_dirty(resource)) {
+				if (!gom_resource_save(resource, error)) {
+					return FALSE;
+				}
 			}
 		}
 		gom_clear_pointer(&priv->to_add, g_ptr_array_unref);


Added precise timer methods for timing elapsed time.

--- Sources/Support/FUMacros.h
+++ Sources/Support/FUMacros.h
@@ -5,6 +5,8 @@
 //  Created by Hart David on 24.02.12.
 //  Copyright (c) 2012 hart[dev]. All rights reserved.
 //
+
+#import <mach/mach_time.h>

 #ifdef TEST
@@ -16,3 +18,18 @@

 #define FUThrow(format, ...) @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:[NSString stringWithFormat:format, ##__VA_ARGS__] userInfo:nil]
 #define FUAssert(condition, format, ...) do { if (!(condition)) FUThrow(format, ##__VA_ARGS__); } while(0)
+
+#define FUTimerStart() \
+	static uint64_t __totalTime = 0; \
+	static uint64_t __sampleCount = 0; \
+	uint64_t __startTime = mach_absolute_time();
+#define FUTimerEnd() \
+	uint64_t __endTime = mach_absolute_time(); \
+	__totalTime += __endTime - __startTime; \
+	__sampleCount++; \
+	if (__sampleCount % 1000 == 0) { \
+		mach_timebase_info_data_t __timer; \
+		mach_timebase_info(&__timer); \
+		uint64_t __time = (__totalTime / __sampleCount) * __timer.numer / __timer.denom; \
+		NSLog(@"%@ Timer: %quns", NSStringFromSelector(_cmd), __time); \
+	}


rebuild-epub: move a couple of lines

rebuild-epub: move a couple of lines

--- src/rebuild-epub/rebuild-epub.c
+++ src/rebuild-epub/rebuild-epub.c
@@ -34,12 +34,11 @@
     strcat(outname, ".new");

     infile = fopen(inname, "r");
-    outfile = fopen(outname, "w");
-
     inarc = archive_read_new();
     archive_read_support_format_zip(inarc);
     archive_read_open_FILE(inarc, infile);

+    outfile = fopen(outname, "w");
     outarc = archive_write_new();
     archive_write_set_format_zip(outarc);
     archive_write_open_FILE(outarc, outfile);


remove copyright, switch to AOSP license

Change-Id: I53485386d68726f5c0596ac842e6a480d4463b74

--- edifyscripting.c
+++ edifyscripting.c
@@ -1,6 +1,18 @@
-// Copyright ClockworkMod, LLC. Reference and porting purposes only. Usage of the extendedcommand API
-// is restricted to those granted explicit permission, or by use of the ROM Manager Recovery API.
-// https://github.com/koush/TestRomManager
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>


sjhill needs to buy donuts for everyone

sjhill needs to buy donuts for everyone

--- libc/sysdeps/linux/common/bits/kernel_sigaction.h
+++ libc/sysdeps/linux/common/bits/kernel_sigaction.h
@@ -41,7 +41,6 @@
     __sighandler_t  k_sa_handler;
     unsigned int    sa_flags;
     unsigned long   sa_mask;
-#endif
 };
 #define _KERNEL_NSIG           128
 #define _KERNEL_NSIG_BPW       32


rawcookie

rawcookie

--- swoole_http.c
+++ swoole_http.c
@@ -864,16 +864,15 @@
     SW_CHECK_RETURN(ret);
 }

-
-
-static void _setcookie(int encode)
+PHP_METHOD(swoole_http_response, cookie)
 {
     char *name, *value = NULL, *path = NULL, *domain = NULL;
     long expires = 0;
+    int encode = 1;
     zend_bool secure = 0, httponly = 0;
     int name_len, value_len = 0, path_len = 0, domain_len = 0;

-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|slssbbb", &name, &name_len, &value, &value_len, &expires,
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|slssbb", &name, &name_len, &value, &value_len, &expires,
                 &path, &path_len, &domain, &domain_len, &secure, &httponly) == FAILURE)
     {
         return;
@@ -991,14 +990,130 @@
     efree(cookie);
 }

-PHP_METHOD(swoole_http_response, cookie)
-{
-    _setcookie(1);
-}
-
 PHP_METHOD(swoole_http_response, rawcookie)
 {
-    _setcookie(0);
+    char *name, *value = NULL, *path = NULL, *domain = NULL;
+    long expires = 0;
+    int encode = 0;
+    zend_bool secure = 0, httponly = 0;
+    int name_len, value_len = 0, path_len = 0, domain_len = 0;
+
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|slssbb", &name, &name_len, &value, &value_len, &expires,
+                &path, &path_len, &domain, &domain_len, &secure, &httponly) == FAILURE)
+    {
+        return;
+    }
+
+    zval *zfd = zend_read_property(swoole_http_response_class_entry_ptr, getThis(), ZEND_STRL("fd"), 0 TSRMLS_CC);
+    if (ZVAL_IS_NULL(zfd))
+    {
+        php_error_docref(NULL TSRMLS_CC, E_WARNING, "http client not exists.");
+        RETURN_FALSE;
+    }
+
+    http_client *client = swHashMap_find_int(php_sw_http_clients, Z_LVAL_P(zfd));
+    if (!client)
+    {
+        php_error_docref(NULL TSRMLS_CC, E_WARNING, "http client[#%d] not exists.", (int) Z_LVAL_P(zfd));
+        RETURN_FALSE;
+    }
+
+    if (client->end)
+    {
+        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Response is end.");
+        RETURN_FALSE;
+    }
+
+    char *cookie, *encoded_value = NULL;
+    int len = sizeof("Set-Cookie: ");
+    char *dt;
+
+    if (name && strpbrk(name, "=,; \t\r\n\013\014") != NULL)
+    {
+        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cookie names cannot contain any of the following '=,; \\t\\r\\n\\013\\014'");
+        RETURN_FALSE;
+    }
+
+    if (!client->response.cookie)
+    {
+        client->response.cookie = swString_new(1024);
+    }
+
+    len += name_len;
+    if (encode && value)
+    {
+        int encoded_value_len;
+        encoded_value = php_url_encode(value, value_len, &encoded_value_len);
+        len += encoded_value_len;
+    }
+    else if (value)
+    {
+        encoded_value = estrdup(value);
+        len += value_len;
+    }
+    if (path)
+    {
+        len += path_len;
+    }
+    if (domain)
+    {
+        len += domain_len;
+    }
+
+    cookie = emalloc(len + 100);
+
+    if (value && value_len == 0)
+    {
+        dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T") - 1, 1, 0 TSRMLS_CC);
+        snprintf(cookie, len + 100, "Set-Cookie: %s=deleted; expires=%s", name, dt);
+        efree(dt);
+    }
+    else
+    {
+        snprintf(cookie, len + 100, "Set-Cookie: %s=%s", name, value ? encoded_value : "");
+        if (expires > 0)
+        {
+            const char *p;
+            strlcat(cookie, "; expires=", len + 100);
+            dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T") - 1, expires, 0 TSRMLS_CC);
+            p = zend_memrchr(dt, '-', strlen(dt));
+            if (!p || *(p + 5) != ' ')
+            {
+                efree(dt);
+                efree(cookie);
+                efree(encoded_value);
+                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expiry date cannot have a year greater than 9999");
+                RETURN_FALSE;
+            }
+            strlcat(cookie, dt, len + 100);
+            efree(dt);
+        }
+    }
+    if (encoded_value)
+    {
+        efree(encoded_value);
+    }
+    if (path && path_len > 0)
+    {
+        strlcat(cookie, "; path=", len + 100);
+        strlcat(cookie, path, len + 100);
+    }
+    if (domain && domain_len > 0)
+    {
+        strlcat(cookie, "; domain=", len + 100);
+        strlcat(cookie, domain, len + 100);
+    }
+    if (secure)
+    {
+        strlcat(cookie, "; secure", len + 100);
+    }
+    if (httponly)
+    {
+        strlcat(cookie, "; httponly", len + 100);
+    }
+    swString_append_ptr(client->response.cookie, cookie, strlen(cookie));
+    swString_append_ptr(client->response.cookie, ZEND_STRL("\r\n"));
+    efree(cookie);
 }

 PHP_METHOD(swoole_http_response, status)


The CHIOGSTATUS ioctl of the SCSI media changer driver (sys/scsi/ch.c)
is broken.  It omits the SCSI_DATA_IN flag in the SCSI READ ELEMENT
STATUS command, which makes the 'chio status' command fail.

PR:		6528
Reviewed by:	phk
Submitted by:	Hans Huebner <hans@artcom.de>

--- sys/scsi/ch.c
+++ sys/scsi/ch.c
@@ -33,7 +33,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *      $Id: ch.c,v 1.43 1998/01/24 02:54:48 eivind Exp $
+ *      $Id: ch.c,v 1.44 1998/04/16 12:28:30 peter Exp $
  */

 #include "opt_devfs.h"
@@ -628,7 +628,7 @@
 	 * Send command to changer.
 	 */
 	return (scsi_scsi_cmd(sc->sc_link, (struct scsi_generic *)&cmd,
-	    sizeof(cmd), (u_char *)data, datalen, CHRETRIES, 100000, NULL, 0));
+	    sizeof(cmd), (u_char *)data, datalen, CHRETRIES, 100000, NULL, SCSI_DATA_IN));
 }


fix minor encoding redundancy for a32

fix minor encoding redundancy for a32

--- core/config/rtarch_a32.h
+++ core/config/rtarch_a32.h
@@ -306,12 +306,12 @@

 #define andxx_ri(RM, IM)                                                    \
         AUZ(EMPTY,    VAL(IM), TIxx,    EMPTY,   EMPTY,   EMPTY2, G2(IM))   \
-        EMITW(0x6A000000 | MIM(REG(RM), REG(RM), VAL(IM), T2(IM), M2(IM)))
+        EMITW(0x60000000 | MIM(REG(RM), REG(RM), VAL(IM), T2(IM), M2(IM)))

 #define andxx_mi(RM, DP, IM)                                                \
         AUZ(SIB(RM),  VAL(IM), TIxx,    MOD(RM), VAL(DP), C1(DP), G2(IM))   \
         EMITW(0xB9400000 | MDM(TMxx,    MOD(RM), VAL(DP), B1(DP), P1(DP)))  \
-        EMITW(0x6A000000 | MIM(TMxx,    TMxx,    VAL(IM), T2(IM), M2(IM)))  \
+        EMITW(0x60000000 | MIM(TMxx,    TMxx,    VAL(IM), T2(IM), M2(IM)))  \
         EMITW(0xB9000000 | MDM(TMxx,    MOD(RM), VAL(DP), B1(DP), P1(DP)))

 #define andxx_rr(RG, RM)                                                    \
@@ -333,12 +333,12 @@

 #define orrxx_ri(RM, IM)                                                    \
         AUZ(EMPTY,    VAL(IM), TIxx,    EMPTY,   EMPTY,   EMPTY2, G2(IM))   \
-        EMITW(0x2A000000 | MIM(REG(RM), REG(RM), VAL(IM), T2(IM), M2(IM)))
+        EMITW(0x20000000 | MIM(REG(RM), REG(RM), VAL(IM), T2(IM), M2(IM)))

 #define orrxx_mi(RM, DP, IM)                                                \
         AUZ(SIB(RM),  VAL(IM), TIxx,    MOD(RM), VAL(DP), C1(DP), G2(IM))   \
         EMITW(0xB9400000 | MDM(TMxx,    MOD(RM), VAL(DP), B1(DP), P1(DP)))  \
-        EMITW(0x2A000000 | MIM(TMxx,    TMxx,    VAL(IM), T2(IM), M2(IM)))  \
+        EMITW(0x20000000 | MIM(TMxx,    TMxx,    VAL(IM), T2(IM), M2(IM)))  \
         EMITW(0xB9000000 | MDM(TMxx,    MOD(RM), VAL(DP), B1(DP), P1(DP)))

 #define orrxx_rr(RG, RM)                                                    \
@@ -360,12 +360,12 @@

 #define xorxx_ri(RM, IM)                                                    \
         AUZ(EMPTY,    VAL(IM), TIxx,    EMPTY,   EMPTY,   EMPTY2, G2(IM))   \
-        EMITW(0x4A000000 | MIM(REG(RM), REG(RM), VAL(IM), T2(IM), M2(IM)))
+        EMITW(0x40000000 | MIM(REG(RM), REG(RM), VAL(IM), T2(IM), M2(IM)))

 #define xorxx_mi(RM, DP, IM)                                                \
         AUZ(SIB(RM),  VAL(IM), TIxx,    MOD(RM), VAL(DP), C1(DP), G2(IM))   \
         EMITW(0xB9400000 | MDM(TMxx,    MOD(RM), VAL(DP), B1(DP), P1(DP)))  \
-        EMITW(0x4A000000 | MIM(TMxx,    TMxx,    VAL(IM), T2(IM), M2(IM)))  \
+        EMITW(0x40000000 | MIM(TMxx,    TMxx,    VAL(IM), T2(IM), M2(IM)))  \
         EMITW(0xB9000000 | MDM(TMxx,    MOD(RM), VAL(DP), B1(DP), P1(DP)))

 #define xorxx_rr(RG, RM)                                                    \


Included nettle/sha1.h

Included nettle/sha1.h

--- pla/crypto.h
+++ pla/crypto.h
@@ -27,6 +27,7 @@
 #include "pla/string.h"
 #include "pla/stream.h"

+#include <nettle/sha1.h>
 #include <nettle/sha2.h>
 #include <nettle/rsa.h>
 #include <gnutls/gnutls.h>


Correctly handle dh key generation when using libressl

Motivation:

Commit f070b9167ac6e2dced746193838000dd6e99a122 changed an ifdef when using libressl to enable generation of temporary dh keys. Unfortunally I missed to also update another ifdef and so SSL.initialize() fails when using libressl now.

Modifications:

Update other ifdef as well.

Result:

netty-tcnative is usable again with libressl.

--- openssl-dynamic/src/main/c/sslutils.c
+++ openssl-dynamic/src/main/c/sslutils.c
@@ -205,7 +205,7 @@
     return (int)strlen(buf);
 }

-#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(OPENSSL_USE_DEPRECATED)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(OPENSSL_USE_DEPRECATED) || defined(LIBRESSL_VERSION_NUMBER)

 static unsigned char dh0512_p[]={
     0xD9,0xBA,0xBF,0xFD,0x69,0x38,0xC9,0x51,0x2D,0x19,0x37,0x39,


Add virtual destructor to IndexerWorklist

Reviewers: #core_team, shahms

Reviewed By: #core_team, shahms

Differential Revision: https://phabricator-dot-kythe-repo.appspot.com/D1295

--- kythe/cxx/indexer/cxx/indexer_worklist.h
+++ kythe/cxx/indexer/cxx/indexer_worklist.h
@@ -108,6 +108,8 @@
   /// \brief Perform one or more units of work.
   /// \return true if these is more work to be done.
   virtual bool DoWork() = 0;
+
+  virtual ~IndexerWorklist() { }
 };

 }  // namespace kythe


Bug fix to for

Bug fix to for

--- interpreter/interpreter.c
+++ interpreter/interpreter.c
@@ -473,15 +473,21 @@
 	currentPoint+=sizeof(unsigned short);

 	char * ptr;
-	int arrSize;
+	int singleSize, arrSize=1, i;
+	unsigned char numDims;
 	cpy(&ptr, expressionVal.data, sizeof(char*));
-	cpy(&arrSize, ptr, sizeof(int));
+	cpy(&numDims, ptr, sizeof(unsigned char));
+	for (i=0;i<numDims;i++) {
+        cpy(&singleSize, &ptr[1+(i*sizeof(unsigned int))], sizeof(unsigned int));
+        arrSize*=singleSize;
+	}
+	size_t headersize=headersize=sizeof(unsigned char) + (sizeof(unsigned int) * numDims);
 	struct value_defn varVal=getVariableValue(incrementVarSymbol, -1);
 	int incrementVal=getInt(varVal.data);
 	if (incrementVal < arrSize) {
 		struct value_defn nextElement;
 		nextElement.type=expressionVal.type;
-		cpy(&nextElement.data, ptr+((incrementVal+1)*4), sizeof(int));
+		cpy(&nextElement.data, ptr+((incrementVal*sizeof(int)) + headersize), sizeof(int));
 		setVariableValue(variantVarSymbol, nextElement, -1);
 		return currentPoint;
 	}


Call g_source_remove when destoying channel

ref: https://github.com/lxde/menu-cache/issues/7

It seems that even if the client side of *socket* is already
closed, the server side cannot receive POLLHUP. And when
it already happened, at the time the server tries to write
into the socket, SIGPIPE is received, then we firstly know that
the client is already closed.

Also, then closing GIOChannel, we must explicitly remove the
"source" added by g_io_add_watch, otherwise we see 100 percent
CPU usage by poll.

So we must register source id as well as channel simultaneously,
and call shutdown function explicitly when we receive
SIGPIPE.

--- menu-cache-daemon/menu-cached.c
+++ menu-cache-daemon/menu-cached.c
@@ -76,6 +76,11 @@
     char *cache_file;
 }Cache;

+typedef struct ClientIO_ {
+    guint source_id;
+    GIOChannel *channel;
+} ClientIO;
+
 static GMainLoop* main_loop = NULL;

 static GHashTable* hash = NULL;
@@ -84,6 +89,8 @@

 static void on_file_changed( GFileMonitor* mon, GFile* gf, GFile* other,
                              GFileMonitorEvent evt, Cache* cache );
+
+static void on_client_closed(gpointer user_data);

 static gboolean delayed_cache_free(gpointer data)
 {
@@ -317,9 +324,12 @@
     /* notify the clients that reload is needed. */
     for( l = cache->clients; l; l = l->next )
     {
-        GIOChannel* ch = (GIOChannel*)l->data;
+        ClientIO *channel_io = (ClientIO *)l->data;
+        GIOChannel* ch = channel_io->channel;
         if(write(g_io_channel_unix_get_fd(ch), buf, 37) < 37)
-            g_io_channel_shutdown(ch, FALSE, NULL);
+        {
+            on_client_closed(channel_io);
+        }
     }
     cache->need_reload = FALSE;
 }
@@ -503,16 +513,18 @@

 static void on_client_closed(gpointer user_data)
 {
-    GIOChannel* ch = user_data;
+    ClientIO* client_io = user_data;
     GHashTableIter it;
     char* md5;
     Cache* cache;
     GSList *l;
+    GIOChannel *ch = client_io->channel;
+
     DEBUG("client closed: %p", ch);
     g_hash_table_iter_init (&it, hash);
     while( g_hash_table_iter_next (&it, (gpointer*)&md5, (gpointer*)&cache) )
     {
-        while((l = g_slist_find( cache->clients, ch )) != NULL)
+        while((l = g_slist_find( cache->clients, client_io )) != NULL)
         {
             /* FIXME: some clients are closed accidentally without
              * unregister the menu first due to crashes.
@@ -530,6 +542,9 @@
         }
     }
     /* DEBUG("client closed"); */
+
+    g_source_remove(client_io->source_id);
+    g_free(client_io);
 }

 static gboolean on_client_data_in(GIOChannel* ch, GIOCondition cond, gpointer user_data)
@@ -544,6 +559,7 @@

     if(cond & (G_IO_HUP|G_IO_ERR) )
     {
+        on_client_closed(user_data);
         return FALSE; /* remove the watch */
     }

@@ -551,8 +567,10 @@
     st = g_io_channel_read_line( ch, &line, &len, NULL, NULL );
     if( st == G_IO_STATUS_AGAIN )
         goto retry;
-    if( st != G_IO_STATUS_NORMAL )
-        return FALSE;
+    if( st != G_IO_STATUS_NORMAL ) {
+        on_client_closed(user_data);
+        return FALSE;
+    }

     --len;
     line[len] = 0;
@@ -659,7 +677,7 @@
             }
         }
         /* DEBUG("menu %s requested by client %d", md5, g_io_channel_unix_get_fd(ch)); */
-        cache->clients = g_slist_prepend(cache->clients, ch);
+        cache->clients = g_slist_prepend(cache->clients, user_data);
         if(cache->delayed_free_handler)
         {
             g_source_remove(cache->delayed_free_handler);
@@ -685,7 +703,7 @@
         if(cache && cache->clients)
         {
             /* remove the IO channel from the cache */
-            cache->clients = g_slist_remove(cache->clients, ch);
+            cache->clients = g_slist_remove(cache->clients, user_data);
             if(cache->clients == NULL)
                 cache_free(cache);
         }
@@ -703,6 +721,7 @@
     socklen_t client_addrlen;
     struct sockaddr client_addr;
     GIOChannel* child;
+    ClientIO* client_io;

     server = g_io_channel_unix_get_fd(ch);

@@ -716,8 +735,12 @@

     child = g_io_channel_unix_new(client);
     g_io_channel_set_close_on_unref( child, TRUE );
-    g_io_add_watch_full(child, G_PRIORITY_DEFAULT, G_IO_PRI|G_IO_IN|G_IO_HUP|G_IO_ERR,
-                        on_client_data_in, child, on_client_closed);
+
+    client_io = g_new0 (ClientIO, 1);
+    client_io->channel = child;
+    client_io->source_id =
+        g_io_add_watch(child, G_IO_PRI|G_IO_IN|G_IO_HUP|G_IO_ERR,
+                        on_client_data_in, client_io);
     g_io_channel_unref(child);

     DEBUG("new client accepted: %p", child);
@@ -823,7 +846,6 @@
     ch = g_io_channel_unix_new(server_fd);
     if(!ch)
         return 1;
-    g_io_channel_set_close_on_unref(ch, TRUE);
     g_io_add_watch(ch, G_IO_IN|G_IO_PRI, on_new_conn_incoming, NULL);
     g_io_add_watch(ch, G_IO_ERR, on_server_conn_close, NULL);
     g_io_channel_unref(ch);


Run userscripts on DOMContentsLoaded

Run userscripts on DOMContentsLoaded

--- midori/midori-addons.c
+++ midori/midori-addons.c
@@ -171,12 +171,14 @@
     gboolean result = FALSE;
     gchar* script;
     GError* error = NULL;
+    gchar* wrapped_script;

     if (g_file_get_contents (filename, &script, NULL, &error))
     {
         /* Wrap the script to prevent global variables */
-        gchar* wrapped_script = g_strdup_printf (
-            "(function () { %s })();", script);
+        wrapped_script = g_strdup_printf (
+            "window.addEventListener ('DOMContentLoaded',"
+            "function () { %s }, true);", script);
         if (gjs_script_eval (js_context, wrapped_script, exception))
             result = TRUE;
         g_free (wrapped_script);


removed FPSCallback

removed FPSCallback

git-svn-id: 5398946ba177a3e438c2dae55e2cdfc2fb96c905@5889 a9d63959-f2ad-4865-b262-bf0e56cfafb6

--- visualization/include/pcl/visualization/common/common.h
+++ visualization/include/pcl/visualization/common/common.h
@@ -135,17 +135,6 @@
         template<typename PointT> void
         cvtWindowCoordinates (const PointT& pt, Eigen::Vector4d& window_cord, const Eigen::Matrix4d& composite_mat);
     };
-
-    //////////////////////////////////////////////////////////////////////////////////////////////
-    class PCL_EXPORTS FPSCallback : public vtkCommand
-    {
-      public:
-        static FPSCallback *New () { return new FPSCallback;}
-        inline void setTextActor (vtkTextActor *txt) { this->actor_ = txt; }
-        virtual void Execute (vtkObject *, unsigned long, void*);
-      protected:
-        vtkTextActor *actor_;
-    };
   }
 }


3次元画像に対するラベリングで，境界のチェックがおかしかったのを修正

3次元画像に対するラベリングで，境界のチェックがおかしかったのを修正

git-svn-id: 3507153f7f2a502978d43a270f21b34bb2e07470@410 b31369ee-dac5-0310-8161-cccb92f82ee5

--- mist/filter/labeling.h
+++ mist/filter/labeling.h
@@ -22,6 +22,143 @@
 // mistOԂ̎n܂
 _MIST_BEGIN

+
+//! @addtogroup labeling_group xO
+//!  @{
+
+
+/// @brief ֐ENX̊Tv
+//!
+//! ڍׂȐ֐̎gp
+//!
+//! @param[in]  in        c ̐
+//! @param[out] out       c ̐
+//! @param[in]  max_label c ̐
+//! @return               c ߂l̐
+//!
+template < class T1, class T2, class Allocator1, class Allocator2 >
+typename array2< T2, Allocator2 >::size_type labeling4( const array2< T1, Allocator1 > &in, array2< T2, Allocator2 > &out, typename array2< T2, Allocator2 >::size_type max_label = __labeling_controller__::default_label_num2< T2 >::value )
+{
+	typedef typename array2< T2, Allocator2 >::size_type  size_type;
+	typedef typename array2< T2, Allocator2 >::value_type value_type;
+
+	if( max_label == 0 )
+	{
+		max_label = type_limits< value_type >::maximum( );
+	}
+
+	out.resize( in.size1( ), in.size2( ) );
+	out.reso1( in.reso1( ) );
+	out.reso2( in.reso2( ) );
+
+	for( size_type i = 0 ; i < in.size( ) ; i++ )
+	{
+		out[ i ] = in[ i ] > 0 ? 1 : 0;
+	}
+	return( __labeling_controller__::labeling( out, max_label, __labeling_controller__::neighbors< 4 >( ) ) );
+}
+
+
+/// @brief ֐ENX̊Tv
+//!
+//! ڍׂȐ֐̎gp
+//!
+//! @param[in]  in        c ̐
+//! @param[out] out       c ̐
+//! @param[in]  max_label c ̐
+//! @return               c ߂l̐
+//!
+template < class T1, class T2, class Allocator1, class Allocator2 >
+typename array2< T2, Allocator2 >::size_type labeling8( const array2< T1, Allocator1 > &in, array2< T2, Allocator2 > &out, typename array2< T2, Allocator2 >::size_type max_label = __labeling_controller__::default_label_num2< T2 >::value )
+{
+	typedef typename array2< T2, Allocator2 >::size_type  size_type;
+	typedef typename array2< T2, Allocator2 >::value_type value_type;
+
+	if( max_label == 0 )
+	{
+		max_label = type_limits< value_type >::maximum( );
+	}
+
+	out.resize( in.size1( ), in.size2( ) );
+	out.reso1( in.reso1( ) );
+	out.reso2( in.reso2( ) );
+
+	for( size_type i = 0 ; i < in.size( ) ; i++ )
+	{
+		out[ i ] = in[ i ] > 0 ? 1 : 0;
+	}
+	return( __labeling_controller__::labeling( out, max_label, __labeling_controller__::neighbors< 8 >( ) ) );
+}
+
+
+/// @brief ֐ENX̊Tv
+//!
+//! ڍׂȐ֐̎gp
+//!
+//! @param[in]  in        c ̐
+//! @param[out] out       c ̐
+//! @param[in]  max_label c ̐
+//! @return               c ߂l̐
+//!
+template < class T1, class T2, class Allocator1, class Allocator2 >
+typename array3< T2, Allocator2 >::size_type labeling6( const array3< T1, Allocator1 > &in, array3< T2, Allocator2 > &out, typename array3< T2, Allocator2 >::size_type max_label = __labeling_controller__::default_label_num3< T2 >::value )
+{
+	typedef typename array3< T2, Allocator2 >::size_type  size_type;
+	typedef typename array3< T2, Allocator2 >::value_type value_type;
+
+	if( max_label == 0 )
+	{
+		max_label = type_limits< value_type >::maximum( );
+	}
+
+	out.resize( in.size1( ), in.size2( ), in.size3( ) );
+	out.reso1( in.reso1( ) );
+	out.reso2( in.reso2( ) );
+	out.reso3( in.reso3( ) );
+
+	for( size_type i = 0 ; i < in.size( ) ; i++ )
+	{
+		out[ i ] = in[ i ] > 0 ? 1 : 0;
+	}
+	return( __labeling_controller__::labeling( out, max_label, __labeling_controller__::neighbors< 6 >( ) ) );
+}
+
+
+/// @brief ֐ENX̊Tv
+//!
+//! ڍׂȐ֐̎gp
+//!
+//! @param[in]  in        c ̐
+//! @param[out] out       c ̐
+//! @param[in]  max_label c ̐
+//! @return               c ߂l̐
+//!
+template < class T1, class T2, class Allocator1, class Allocator2 >
+typename array3< T2, Allocator2 >::size_type labeling26( const array3< T1, Allocator1 > &in, array3< T2, Allocator2 > &out, typename array3< T2, Allocator2 >::size_type max_label = __labeling_controller__::default_label_num3< T2 >::value )
+{
+	typedef typename array3< T2, Allocator2 >::size_type  size_type;
+	typedef typename array3< T2, Allocator2 >::value_type value_type;
+
+	if( max_label == 0 )
+	{
+		max_label = type_limits< value_type >::maximum( );
+	}
+
+	out.resize( in.size1( ), in.size2( ), in.size3( ) );
+	out.reso1( in.reso1( ) );
+	out.reso2( in.reso2( ) );
+	out.reso3( in.reso3( ) );
+
+	for( size_type i = 0 ; i < in.size( ) ; i++ )
+	{
+		out[ i ] = in[ i ] > 0 ? 1 : 0;
+	}
+	return( __labeling_controller__::labeling( out, max_label, __labeling_controller__::neighbors< 26 >( ) ) );
+}
+
+/// @}
+//  xOO[v̏I
+}

 namespace __labeling_controller__
@@ -78,14 +215,14 @@
 			L[  2 ] = i     > 0                       ? T[ static_cast< size_type >( in( i - 1, j    , k     ) ) ] : 0;
 			L[  3 ] =              j     > 0 && k > 0 ? T[ static_cast< size_type >( in( i    , j - 1, k - 1 ) ) ] : 0;
 			L[  4 ] = i     > 0 &&              k > 0 ? T[ static_cast< size_type >( in( i - 1, j    , k - 1 ) ) ] : 0;
-			L[  5 ] = i + 1 > w &&              k > 0 ? T[ static_cast< size_type >( in( i + 1, j    , k - 1 ) ) ] : 0;
-			L[  6 ] =              j + 1 > h && k > 0 ? T[ static_cast< size_type >( in( i    , j + 1, k - 1 ) ) ] : 0;
+			L[  5 ] = i + 1 < w &&              k > 0 ? T[ static_cast< size_type >( in( i + 1, j    , k - 1 ) ) ] : 0;
+			L[  6 ] =              j + 1 < h && k > 0 ? T[ static_cast< size_type >( in( i    , j + 1, k - 1 ) ) ] : 0;
 			L[  7 ] = i     > 0 && j     > 0          ? T[ static_cast< size_type >( in( i - 1, j - 1, k     ) ) ] : 0;
-			L[  8 ] = i + 1 > w && j     > 0          ? T[ static_cast< size_type >( in( i + 1, j - 1, k     ) ) ] : 0;
+			L[  8 ] = i + 1 < w && j     > 0          ? T[ static_cast< size_type >( in( i + 1, j - 1, k     ) ) ] : 0;
 			L[  9 ] = i     > 0 && j     > 0 && k > 0 ? T[ static_cast< size_type >( in( i - 1, j - 1, k - 1 ) ) ] : 0;
-			L[ 10 ] = i + 1 > w && j     > 0 && k > 0 ? T[ static_cast< size_type >( in( i + 1, j - 1, k - 1 ) ) ] : 0;
-			L[ 11 ] = i     > 0 && j + 1 > h && k > 0 ? T[ static_cast< size_type >( in( i - 1, j + 1, k - 1 ) ) ] : 0;
-			L[ 12 ] = i + 1 > w && j + 1 > h && k > 0 ? T[ static_cast< size_type >( in( i + 1, j + 1, k - 1 ) ) ] : 0;
+			L[ 10 ] = i + 1 < w && j     > 0 && k > 0 ? T[ static_cast< size_type >( in( i + 1, j - 1, k - 1 ) ) ] : 0;
+			L[ 11 ] = i     > 0 && j + 1 < h && k > 0 ? T[ static_cast< size_type >( in( i - 1, j + 1, k - 1 ) ) ] : 0;
+			L[ 12 ] = i + 1 < w && j + 1 < h && k > 0 ? T[ static_cast< size_type >( in( i + 1, j + 1, k - 1 ) ) ] : 0;
 		}
 	};

@@ -106,10 +243,10 @@
 			L[  2 ] = i     > 0                       ? T[ static_cast< size_type >( in( i - 1, j    , k     ) ) ] : 0;
 			L[  3 ] =              j     > 0 && k > 0 ? T[ static_cast< size_type >( in( i    , j - 1, k - 1 ) ) ] : 0;
 			L[  4 ] = i     > 0 &&              k > 0 ? T[ static_cast< size_type >( in( i - 1, j    , k - 1 ) ) ] : 0;
-			L[  5 ] = i + 1 > w &&              k > 0 ? T[ static_cast< size_type >( in( i + 1, j    , k - 1 ) ) ] : 0;
-			L[  6 ] =              j + 1 > h && k > 0 ? T[ static_cast< size_type >( in( i    , j + 1, k - 1 ) ) ] : 0;
+			L[  5 ] = i + 1 < w &&              k > 0 ? T[ static_cast< size_type >( in( i + 1, j    , k - 1 ) ) ] : 0;
+			L[  6 ] =              j + 1 < h && k > 0 ? T[ static_cast< size_type >( in( i    , j + 1, k - 1 ) ) ] : 0;
 			L[  7 ] = i     > 0 && j     > 0          ? T[ static_cast< size_type >( in( i - 1, j - 1, k     ) ) ] : 0;
-			L[  8 ] = i + 1 > w && j     > 0          ? T[ static_cast< size_type >( in( i + 1, j - 1, k     ) ) ] : 0;
+			L[  8 ] = i + 1 < w && j     > 0          ? T[ static_cast< size_type >( in( i + 1, j - 1, k     ) ) ] : 0;
 		}
 	};


TSCH: implement off()

TSCH: implement off()


Reset nopath_received flag when new DAO is received

--- core/net/rpl/rpl-icmp6.c
+++ core/net/rpl/rpl-icmp6.c
@@ -777,6 +777,7 @@

   rep->state.lifetime = RPL_LIFETIME(instance, lifetime);
   rep->state.learned_from = learned_from;
+  rep->state.nopath_received = 0;

 #if RPL_CONF_MULTICAST
 fwd_dao:


Stability fix

Stability fix

--- core/system/systembase.c
+++ core/system/systembase.c
@@ -2509,7 +2509,7 @@

 					wsc = (WebsocketServerClient *)wsc->node.mln_Succ;
 				}
-				FRIEND_MUTEX_UNLOCK( &(l->sl_USM->usm_Mutex) )
+				FRIEND_MUTEX_UNLOCK( &(l->sl_USM->usm_Mutex) );
 			}

 			FFree( buf );


Correct pointer hotspot location.

Correct pointer hotspot location.

--- egl-compositor.c
+++ egl-compositor.c
@@ -671,9 +671,10 @@
 		      struct wl_object *source, int x, int y)
 {
 	struct egl_compositor *ec = (struct egl_compositor *) compositor;
-
-	ec->pointer->map.x = x;
-	ec->pointer->map.y = y;
+	const int hotspot_x = 16, hotspot_y = 16;
+
+	ec->pointer->map.x = x - hotspot_x;
+	ec->pointer->map.y = y - hotspot_y;
 	schedule_repaint(ec);
 }


added interfaces to the map view controller

--- miataru/MIADMapViewController.h
+++ miataru/MIADMapViewController.h
@@ -7,8 +7,9 @@
 //

 #import <UIKit/UIKit.h>
+#import <MapKit/MapKit.h>

-@interface MIADMapViewController : UIViewController
+@interface MIADMapViewController : UIViewController <NSURLConnectionDelegate,MKMapViewDelegate>

 @property (strong) NSMutableData *responseData;


cpu: Cleanup clearing of doorbells on P9

We currently do a rather pointless msgclr prior to setting
in_sleep/in_idle (with no ordering guarantee which isn't great).

We also do the final msgsync/msgclr after setting in_sleep/in_idle
back to false which while probably ok, isn't that great, we should
do msgsync first thing when waking up.

Finally, do p9_dbell_receive() before skip_sleep.

So take out the first msgclr, swap the final p9_dbell_receive() and
add a sync() for good measure and match what p8 does.

Signed-off-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>
Signed-off-by: Stewart Smith <ec31ab75ddf977353c8f660f92ea8b23f64aef25@linux.ibm.com>

--- core/cpu.c
+++ core/cpu.c
@@ -375,8 +375,6 @@
 		return;
 	}

-	msgclr(); /* flush pending messages */
-
 	/* Synchronize with wakers */
 	if (wake_on == cpu_wake_on_job) {
 		/* Mark ourselves in idle so other CPUs know to send an IPI */
@@ -420,11 +418,14 @@
 		enter_p9_pm_lite_state(psscr);
 	}

-skip_sleep:
+	/* Clear doorbell */
+	p9_dbell_receive();
+
+ skip_sleep:
 	/* Restore */
+	sync();
 	cpu->in_idle = false;
 	cpu->in_sleep = false;
-	p9_dbell_receive();
 }

 static void cpu_idle_pm(enum cpu_wake_cause wake_on)


pci: Wait for CRS and switch link when restoring bus numbers

When a complete reset occurs, after the PHB recovers it propagates a
reset down the wire to every device.  At the same time, skiboot talks to
every device in order to restore the state of devices to what they were
before the reset.

In some situations, such as devices that recovered slowly and/or were
behind a switch, skiboot attempted to access config space of the device
before the link was up and the device could respond.

Fix this by retrying CRS until the device responds correctly, and for
devices behind a switch, making sure the switch has its link up first.

Signed-off-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>
Signed-off-by: Russell Currey <b5ebcef270cdc73fa0593440445c07a93ae1bccb@russell.cc>
Reviewed-by: Andrew Donnellan <efc2d7c347a094a6ec1d918179e819039044c564@au1.ibm.com>
Tested-by: Hari Bathini <8c08e0cbfdd898a4d11cb688ad22c29e30def136@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <ec31ab75ddf977353c8f660f92ea8b23f64aef25@linux.vnet.ibm.com>

--- core/pci.c
+++ core/pci.c
@@ -218,21 +218,18 @@
 	pci_init_pm_cap(phb, pd);
 }

-static struct pci_device *pci_scan_one(struct phb *phb, struct pci_device *parent,
-				       uint16_t bdfn)
-{
-	struct pci_device *pd = NULL;
+static bool pci_wait_crs(struct phb *phb, uint16_t bdfn, uint32_t *out_vdid)
+{
 	uint32_t retries, vdid;
 	int64_t rc;
-	uint8_t htype;
 	bool had_crs = false;

 	for (retries = 0; retries < 40; retries++) {
 		rc = pci_cfg_read32(phb, bdfn, PCI_CFG_VENDOR_ID, &vdid);
 		if (rc)
-			return NULL;
+			return false;
 		if (vdid == 0xffffffff || vdid == 0x00000000)
-			return NULL;
+			return false;
 		if (vdid != 0xffff0001)
 			break;
 		had_crs = true;
@@ -240,10 +237,26 @@
 	}
 	if (vdid == 0xffff0001) {
 		PCIERR(phb, bdfn, "CRS timeout !\n");
-		return NULL;
+		return false;
 	}
 	if (had_crs)
 		PCIDBG(phb, bdfn, "Probe success after %d CRS\n", retries);
+
+	if (out_vdid)
+		*out_vdid = vdid;
+	return true;
+}
+
+static struct pci_device *pci_scan_one(struct phb *phb, struct pci_device *parent,
+				       uint16_t bdfn)
+{
+	struct pci_device *pd = NULL;
+	uint32_t vdid;
+	int64_t rc;
+	uint8_t htype;
+
+	if (!pci_wait_crs(phb, bdfn, &vdid))
+		return NULL;

 	/* Perform a dummy write to the device in order for it to
 	 * capture it's own bus number, so any subsequent error
@@ -1835,14 +1848,26 @@
 				      struct pci_device *pd,
 				      void *data __unused)
 {
-	if (!pd->is_bridge) {
-		uint32_t vdid;
-
-		/* Make all devices below a bridge "re-capture" the bdfn */
-		if (pci_cfg_read32(phb, pd->bdfn, PCI_CFG_VENDOR_ID, &vdid) == 0)
-			pci_cfg_write32(phb, pd->bdfn, PCI_CFG_VENDOR_ID, vdid);
+	uint32_t vdid;
+
+	/* If the device is behind a switch, wait for the switch */
+	if (!pd->is_vf && !(pd->bdfn & 7) && pd->parent != NULL &&
+	    pd->parent->dev_type == PCIE_TYPE_SWITCH_DNPORT) {
+		if (!pci_bridge_wait_link(phb, pd->parent, true)) {
+			PCIERR(phb, pd->bdfn, "Timeout waiting for switch\n");
+			return -1;
+		}
+	}
+
+	/* Wait for config space to stop returning CRS */
+	if (!pci_wait_crs(phb, pd->bdfn, &vdid))
+		return -1;
+
+	/* Make all devices below a bridge "re-capture" the bdfn */
+	pci_cfg_write32(phb, pd->bdfn, PCI_CFG_VENDOR_ID, vdid);
+
+	if (!pd->is_bridge)
 		return 0;
-	}

 	pci_cfg_write8(phb, pd->bdfn, PCI_CFG_PRIMARY_BUS,
 		       pd->primary_bus);