1. Список говнокодов пользователя nsa_a1

    Всего: 2

  2. C++ / Говнокод #14626

    +59

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    #ifndef PORT_H_
    #define PORT_H_
    
    #define MAKE_PORT(portName, ddrName, pinName, className, ID) \
    		class className{\
    		public:\
    			typedef uint8_t DataT; /* Alias for the type of data port*/\
    		private:\
    			static volatile DataT &data()\
    			{\
    				return portName;\
    			}\
    			static volatile DataT &dir()\
    			{\
    				return ddrName;\
    			}\
    			static volatile DataT &pin()\
    			{\
    				return pinName;\
    			}\
    		public:\
    			static void Write(DataT value) /*Write value to port PORT = value*/\
    			{\
    				data() = value;\
    			}\
    			static void ClearAndSet(DataT clearMask, DataT value) /*Clear by mask and set PORT = (PORT & ~clearMask) | value */\
    			{\
    				data() = (data() & ~clearMask) | value;\
    			}\
    			static DataT Read() /*Read the value written to the port*/\
    			{\
    				return data();\
    			}\
    			static void DirWrite(DataT value)/*Record the value of the direction of the lines I/O */\
    			{\
    				dir() = value;\
    			}\
    			static DataT DirRead() /*Read the value of the direction of the lines I/O */\
    			{\
    				return dir();\
    			}\
    			static void Set(DataT value) /*Set bits in the port PORT |= value;*/\
    			{\
    				data() |= value;\
    			}\
    			static void Clear(DataT value) /*Clear bits in the port PORT &= ~value;*/\
    			{\
    				data() &= ~value;\
    			}\
    			static void Togle(DataT value) /*Switch bits PORT ^= value;*/\
    			{\
    				data() ^= value;\
    			}\
    			static void DirSet(DataT value) /*Set direction bits*/\
    			{\
    				dir() |= value;\
    			}\
    			static void DirClear(DataT value) /*Clear direction bits*/\
    			{\
    				dir() &= ~value;\
    			}\
    			static void DirTogle(DataT value)\
    			{\
    				dir() ^= value;\
    			}\
    			static DataT PinRead()\
    			{\
    				return pin();\
    			}\
    			enum{Id = ID};\
    			enum{Width=sizeof(DataT)*8};/*Bit depth*/\
    		};
    
    #ifdef PORTA
    	MAKE_PORT(PORTA, DDRA, PINA, Porta, 'A');
    #endif
    
    #ifdef PORTB
    	MAKE_PORT(PORTB, DDRB, PINB, Portb, 'B');
    #endif
    
    #ifdef PORTC
    	MAKE_PORT(PORTC, DDRC, PINC, Portc, 'C');
    #endif
    
    #ifdef PORTD
    	MAKE_PORT(PORTD, DDRD, PIND, Portd, 'D');
    #endif
    
    
    
    
    #endif /* PORT_H_ */

    Использование СИ++ в микроконтроллерах доставляет....

    nsa_a1, 18 Февраля 2014

    Комментарии (5)
  3. C++ / Говнокод #5286

    +181

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    void MultipleSquareMatrix(Matrix*rres, Matrix*mul1, Matrix* mul2)
    {	
    	int N = mul1->height();
    	Matrix rmul1(N,N);
    	Matrix rmul2(N,N);
    
    	#define SM (CLS / sizeof (double))
    
    	for (i = 0; i < N; i += SM)
    		for (j = 0; j < N; j += SM)
    			for (k = 0; k < N; k += SM)
    				for (i2 = 0, rres = &res[i][j],
    					  rmul1 = &mul1[i][k]; i2 < SM;
    					++i2, rres += N, rmul1 += N)
    					for (k2 = 0, rmul2 = &mul2[k][j];
    						k2 < SM; ++k2, rmul2 += N)
    						for (j2 = 0; j2 < SM; ++j2)
    							rres[j2] += rmul1[k2] * rmul2[j2];
    }

    Перемножение квадратных матриц.....

    nsa_a1, 15 Января 2011

    Комментарии (74)